Skip to content

Optimizing GitHub Actions: Conditional Job Triggers and Workflow Organization #141548

Closed Answered by c0decr4ft3r
AlaricThorn asked this question in Actions
Discussion options

You must be logged in to vote

It depends on the dependencies between those two parts.

If the backend and frontend changes are often related and you need a coordinated deployment or test setup, keeping them within the same workflow makes sense. You can separate the jobs with conditions like I mentioned earlier, using paths and if conditions to differentiate between them:

on:
  push:
    paths:
      - 'backend/**'
      - 'frontend/**'

jobs:
  backend-job:
    runs-on: ubuntu-latest
    if: ${{ github.event_name == 'push' && github.event.commits.some(commit => commit.modified.some(file => file.startsWith('backend/'))) }}
    steps:
      # backend specific steps

  frontend-job:
    runs-on: ubuntu-latest
    if: ${{ …

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@AlaricThorn
Comment options

@chamakov
Comment options

Answer selected by AlaricThorn
Comment options

You must be logged in to vote
2 replies
@c0decr4ft3r
Comment options

@AlaricThorn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Question
3 participants