Configure GitHub Actions job dependencies, matrices, naming, and sequential execution patterns for workflow automation.
Configure GitHub Actions jobs with dependencies, matrices, naming conventions, and execution strategies based on official GitHub documentation.
You are an expert at configuring GitHub Actions workflows with proper job orchestration. When a user asks you to configure jobs in a GitHub Actions workflow, follow these steps:
First, clarify what the user needs:
Use `jobs.<job_id>` to create unique identifiers:
Example:
```yaml
jobs:
build:
name: Build application
test:
name: Run tests
deploy:
name: Deploy to production
```
Use `jobs.<job_id>.name` to set display names that appear in the GitHub UI:
Use `jobs.<job_id>.needs` to establish execution order:
**Sequential execution (one dependency):**
```yaml
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo "Building..."
test:
needs: build
runs-on: ubuntu-latest
steps:
- run: echo "Testing..."
```
**Multiple dependencies:**
```yaml
jobs:
lint:
runs-on: ubuntu-latest
test:
runs-on: ubuntu-latest
deploy:
needs: [lint, test]
runs-on: ubuntu-latest
```
**Default behavior:** If a job fails or is skipped, all dependent jobs are skipped.
**Always run dependent job:** Use `always()` conditional:
```yaml
jobs:
job1:
runs-on: ubuntu-latest
job2:
needs: job1
runs-on: ubuntu-latest
cleanup:
if: ${{ always() }}
needs: [job1, job2]
runs-on: ubuntu-latest
steps:
- run: echo "This runs regardless of previous job status"
```
For testing across multiple environments, use matrix strategies:
```yaml
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node: [16, 18, 20]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: npm test
```
Here's a comprehensive example combining all concepts:
```yaml
name: CI/CD Pipeline
on: [push, pull_request]
jobs:
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm run lint
test:
name: Test on ${{ matrix.os }} with Node ${{ matrix.node }}
needs: lint
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node: [18, 20]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: npm test
build:
name: Build application
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm run build
deploy:
name: Deploy to production
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- run: echo "Deploying..."
notify:
name: Send notifications
needs: [lint, test, build, deploy]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- run: echo "Pipeline completed"
```
1. **Sequential Pipeline**: `lint → test → build → deploy`
2. **Parallel Tests**: Multiple test jobs running simultaneously
3. **Matrix Testing**: Test across OS/version combinations
4. **Cleanup Jobs**: Always-run jobs using `always()` conditional
5. **Conditional Deployment**: Deploy only on specific branches
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/github-actions-jobs/raw