
24 GitHub Actions Workflows for Development Teams
As a development team, you’re likely familiar with the challenges of maintaining a smooth and efficient workflow. From building, testing, and deploying code to managing dependencies and keeping track of changes, there are many moving parts to consider.
That’s where GitHub Actions comes in – a powerful tool that automates your software development workflow directly within your repository. In this article, we’ll explore 24 GitHub Actions workflows to help streamline your development process.
1. Code Formatting
Ensure consistent code formatting across all team members by running a linter on each commit. Create a format
workflow that runs before merging PRs into the main branch.
“`yml
name: Format Code
on:
push:
branches: [main]
jobs:
format:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Run formatter
run: |
npm install prettier –save-dev
npx prettier –write .
“`
2. Code Review
Automate code review by running a linter on each PR. Create a review
workflow that runs before merging PRs into the main branch.
“`yml
name: Code Review
on:
pull_request:
jobs:
review:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Run linter
run: |
npm install eslint –save-dev
npx eslint .
“`
3. Build and Test
Run automated tests on each commit to ensure your code works as expected. Create a build-and-test
workflow that runs before merging PRs into the main branch.
“`yml
name: Build and Test
on:
push:
branches: [main]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install
– name: Run tests
run: npx jest
“`
4. Code Coverage
Measure the code coverage of your tests by running a tool like Istanbul or Coveralls. Create a coverage
workflow that runs after each PR is merged into the main branch.
“`yml
name: Code Coverage
on:
push:
branches: [main]
jobs:
coverage:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install istanbul –save-dev
– name: Run tests with coverage
run: npx jest –coverage
“`
5. Dependency Updates
Automate dependency updates by running a tool like npm-check-updates or yarn upgrade-interactive on each commit. Create a dependencies
workflow that runs before merging PRs into the main branch.
“`yml
name: Dependency Updates
on:
push:
branches: [main]
jobs:
dependencies:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install –save-dev
– name: Update dependencies
run: npx npm-check-updates
“`
6. Security Scanning
Run security scans on each commit to ensure your code is secure. Create a security
workflow that runs before merging PRs into the main branch.
“`yml
name: Security Scanning
on:
push:
branches: [main]
jobs:
security:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install snyk –save-dev
– name: Run security scan
run: npx snyk test .
“`
7. Linter
Run a linter on each commit to ensure your code is clean and consistent. Create a linter
workflow that runs before merging PRs into the main branch.
“`yml
name: Linter
on:
push:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install eslint –save-dev
– name: Run linter
run: npx eslint .
“`
8. ESLint
Run ESLint on each commit to ensure your code is clean and consistent. Create an eslint
workflow that runs before merging PRs into the main branch.
“`yml
name: ESLint
on:
push:
branches: [main]
jobs:
eslint:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install eslint –save-dev
– name: Run ESLint
run: npx eslint .
“`
9. JSHint
Run JSHint on each commit to ensure your code is clean and consistent. Create a jshint
workflow that runs before merging PRs into the main branch.
“`yml
name: JSHint
on:
push:
branches: [main]
jobs:
jshint:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install jshint –save-dev
– name: Run JSHint
run: npx jshint .
“`
10. PHP
Run PHP linters and formatters on each commit to ensure your code is clean and consistent. Create a php
workflow that runs before merging PRs into the main branch.
“`yml
name: PHP
on:
push:
branches: [main]
jobs:
php:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install php-cs-fixer –save-dev
– name: Run PHP linter and formatter
run: npx php-cs-fixer .
“`
11. Python
Run Python linters and formatters on each commit to ensure your code is clean and consistent. Create a python
workflow that runs before merging PRs into the main branch.
“`yml
name: Python
on:
push:
branches: [main]
jobs:
python:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install pylint –save-dev
– name: Run Python linter and formatter
run: npx pylint .
“`
12. Java
Run Java linters and formatters on each commit to ensure your code is clean and consistent. Create a java
workflow that runs before merging PRs into the main branch.
“`yml
name: Java
on:
push:
branches: [main]
jobs:
java:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install checkstyle –save-dev
– name: Run Java linter and formatter
run: npx checkstyle .
“`
13. Go
Run Go linters and formatters on each commit to ensure your code is clean and consistent. Create a go
workflow that runs before merging PRs into the main branch.
“`yml
name: Go
on:
push:
branches: [main]
jobs:
go:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install golint –save-dev
– name: Run Go linter and formatter
run: npx golint .
“`
14. C#
Run C# linters and formatters on each commit to ensure your code is clean and consistent. Create a csharp
workflow that runs before merging PRs into the main branch.
“`yml
name: C#
on:
push:
branches: [main]
jobs:
csharp:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install StyleCop –save-dev
– name: Run C# linter and formatter
run: npx StyleCop .
“`
15. Ruby
Run Ruby linters and formatters on each commit to ensure your code is clean and consistent. Create a ruby
workflow that runs before merging PRs into the main branch.
“`yml
name: Ruby
on:
push:
branches: [main]
jobs:
ruby:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install rubocop –save-dev
– name: Run Ruby linter and formatter
run: npx rubocop .
“`
16. Swift
Run Swift linters and formatters on each commit to ensure your code is clean and consistent. Create a swift
workflow that runs before merging PRs into the main branch.
“`yml
name: Swift
on:
push:
branches: [main]
jobs:
swift:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install swiftlint –save-dev
– name: Run Swift linter and formatter
run: npx swiftlint .
“`
17. PHPStan
Run PHPStan on each commit to ensure your code is clean and consistent. Create a phpstan
workflow that runs before merging PRs into the main branch.
“`yml
name: PHPStan
on:
push:
branches: [main]
jobs:
phpstan:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install –save-dev phpstan/phpstan
– name: Run PHPStan
run: npx phpstan .
“`
18. Psalm
Run Psalm on each commit to ensure your code is clean and consistent. Create a psalm
workflow that runs before merging PRs into the main branch.
“`yml
name: Psalm
on:
push:
branches: [main]
jobs:
psalm:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install –save-dev vimeo/psalm
– name: Run Psalm
run: npx psalm .
“`
19. Funkwerk
Run Funkwerk on each commit to ensure your code is clean and consistent. Create a funkwerk
workflow that runs before merging PRs into the main branch.
“`yml
name: Funkwerk
on:
push:
branches: [main]
jobs:
funkwerk:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install –save-dev funcwerk/funcwerk
– name: Run Funkwerk
run: npx funkwerk .
“`
20. Commitlint
Run Commitlint on each commit to ensure your code is clean and consistent. Create a commitlint
workflow that runs before merging PRs into the main branch.
“`yml
name: Commitlint
on:
push:
branches: [main]
jobs:
commitlint:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install dependencies
run: npm install –save-dev @commitlint/cli
– name: Run Commitlint
run: npx commitlint .
“`
This is a list of some linters and formatters for different programming languages. This list can be used as a starting point to create a workflow that ensures code quality before merging into the main branch.