
16 GitHub Actions Workflows for Development Teams
As a development team, automating repetitive tasks and ensuring consistent workflows can save you time, reduce errors, and increase productivity. GitHub Actions is a powerful tool that allows you to create custom automation workflows directly within your repository. In this article, we’ll explore 16 essential GitHub Actions workflows for development teams.
1. Code Formatting
Automate code formatting using tools like Prettier or ESLint. This ensures consistent coding style across the team and helps catch errors early on.
“`yml
name: Code Formatting
on:
push:
branches: [ main ]
jobs:
format:
runs-on: ubuntu-latest
steps:
– name: Format code with Prettier
run: |
npm install prettier –save-dev
npx prettier –write .
“`
2. Code Review
Enforce code reviews on pull requests using GitHub Actions. This ensures that all code changes are reviewed and approved before merging.
“`yml
name: Code Review
on:
pull_request:
branches: [ main ]
jobs:
review:
runs-on: ubuntu-latest
steps:
– name: Run code review with Codecov
run: |
npm install codecov –save-dev
npx codecov .
“`
3. Build and Test
Automate building and testing your code using GitHub Actions. This ensures that all changes are properly built and tested before deployment.
“`yml
name: Build and Test
on:
push:
branches: [ main ]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
– name: Install dependencies
run: |
npm install .
– name: Run tests with Jest
run: |
npx jest
“`
4. Deploy to Staging
Automate deployment to your staging environment using GitHub Actions. This ensures that all changes are properly deployed and tested in a pre-production environment.
“`yml
name: Deploy to Staging
on:
push:
branches: [ main ]
jobs:
deploy-to-staging:
runs-on: ubuntu-latest
steps:
– name: Deploy to staging with Netlify
run: |
npm install netlify-cli –save-dev
npx netlify deploy –prod –prodBranch=staging
“`
5. Deploy to Production
Automate deployment to your production environment using GitHub Actions. This ensures that all changes are properly deployed and made live.
“`yml
name: Deploy to Production
on:
push:
branches: [ main ]
jobs:
deploy-to-production:
runs-on: ubuntu-latest
steps:
– name: Deploy to prod with Netlify
run: |
npm install netlify-cli –save-dev
npx netlify deploy –prod –prodBranch=production
“`
6. Code Coverage
Enforce code coverage using GitHub Actions. This ensures that all changes have adequate test coverage.
“`yml
name: Code Coverage
on:
push:
branches: [ main ]
jobs:
coverage:
runs-on: ubuntu-latest
steps:
– name: Run code coverage with Istanbul
run: |
npm install istanbul –save-dev
npx istanbul cover .
“`
7. Security Scanning
Automate security scanning using GitHub Actions. This ensures that all changes are properly scanned for potential vulnerabilities.
“`yml
name: Security Scanning
on:
push:
branches: [ main ]
jobs:
scan-security:
runs-on: ubuntu-latest
steps:
– name: Scan for security issues with Snyk
run: |
npm install snyk –save-dev
npx snyk test .
“`
8. Linting
Automate linting using GitHub Actions. This ensures that all code changes are properly formatted and follow best practices.
“`yml
name: Linting
on:
push:
branches: [ main ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
– name: Run linter with ESLint
run: |
npm install eslint –save-dev
npx eslint .
“`
9. Type Checking
Automate type checking using GitHub Actions. This ensures that all code changes are properly typed and follow best practices.
“`yml
name: Type Checking
on:
push:
branches: [ main ]
jobs:
type-checking:
runs-on: ubuntu-latest
steps:
– name: Run type checker with TSC
run: |
npm install typescript –save-dev
npx tsc .
“`
10. Code Smells
Automate code smell detection using GitHub Actions. This ensures that all code changes are properly formatted and follow best practices.
“`yml
name: Code Smells
on:
push:
branches: [ main ]
jobs:
code-smells:
runs-on: ubuntu-latest
steps:
– name: Detect code smells with SonarQube
run: |
npm install sonarqube –save-dev
npx sonarqube .
“`
11. Documentation
Automate documentation using GitHub Actions. This ensures that all code changes are properly documented and follow best practices.
“`yml
name: Documentation
on:
push:
branches: [ main ]
jobs:
doc:
runs-on: ubuntu-latest
steps:
– name: Generate documentation with MkDocs
run: |
npm install mkdocs –save-dev
npx mkdocs .
“`
12. API Testing
Automate API testing using GitHub Actions. This ensures that all code changes are properly tested and follow best practices.
“`yml
name: API Testing
on:
push:
branches: [ main ]
jobs:
api-test:
runs-on: ubuntu-latest
steps:
– name: Run API tests with Postman
run: |
npm install postman –save-dev
npx newman .
“`
13. Performance Testing
Automate performance testing using GitHub Actions. This ensures that all code changes are properly tested and follow best practices.
“`yml
name: Performance Testing
on:
push:
branches: [ main ]
jobs:
perf-test:
runs-on: ubuntu-latest
steps:
– name: Run performance tests with Artillery
run: |
npm install artillery –save-dev
npx artillery .
“`
14. CI/CD
Automate CI/CD using GitHub Actions. This ensures that all code changes are properly built, tested, and deployed.
“`yml
name: CI/CD
on:
push:
branches: [ main ]
jobs:
ci-cd:
runs-on: ubuntu-latest
steps:
– name: Build and deploy with Jenkins
run: |
npm install jenkins –save-dev
npx jenkins .
“`
15. Monitoring
Automate monitoring using GitHub Actions. This ensures that all code changes are properly monitored and follow best practices.
“`yml
name: Monitoring
on:
push:
branches: [ main ]
jobs:
monitor:
runs-on: ubuntu-latest
steps:
– name: Run monitors with Prometheus
run: |
npm install prometheus –save-dev
npx prometheus .
“`
16. Security Auditing
Automate security auditing using GitHub Actions. This ensures that all code changes are properly audited and follow best practices.
“`yml
name: Security Auditing
on:
push:
branches: [ main ]
jobs:
audit-security:
runs-on: ubuntu-latest
steps:
– name: Run security audits with OWASP
run: |
npm install owasp –save-dev
npx owasp .
“`
In conclusion, GitHub Actions provides a powerful tool for automating repetitive tasks and ensuring consistent workflows. By leveraging these 16 essential GitHub Actions workflows for development teams, you can save time, reduce errors, and increase productivity. Remember to customize each workflow according to your specific needs and requirements.
Happy automating!