Created
August 21, 2023 06:48
-
-
Save wiledal/b16cd7f249350dd0ffe054b08dac4457 to your computer and use it in GitHub Desktop.
Github Actions - Monorepo deploy workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deploy frontend after successful backend deployment in sequence | |
# If frontend changed, deploy only frontend | |
# If backend changed, deploy only backend | |
# If frontend and backend, deploy frontend after backend | |
name: "Deploy services" | |
on: | |
push: | |
branches: ["main"] | |
jobs: | |
# JOB to run change detection | |
changes: | |
name: "Filter changed files" | |
runs-on: ubuntu-latest | |
# Set job outputs to values from filter step | |
outputs: | |
backend: ${{ steps.filter.outputs.backend }} | |
frontend: ${{ steps.filter.outputs.frontend }} | |
steps: | |
- uses: actions/checkout@v2 | |
# For pull requests it's not necessary to checkout the code | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
backend: | |
- 'applications/backend/**' | |
frontend: | |
- 'applications/frontend/**' | |
# trigger backend if backend is changed | |
backend: | |
needs: changes | |
if: needs.changes.outputs.backend == 'true' | |
uses: organization/repository/.github/workflows/deploy-backend.yml@main | |
# trigger frontend if only frontend is changed | |
frontend: | |
needs: changes | |
if: needs.changes.outputs.frontend == 'true' && needs.changes.outputs.backend == 'false' | |
uses: organization/repository/.github/workflows/deploy-frontend.yml@main | |
# trigger frontend after backend if both are changed | |
frontend-after-backend: | |
needs: backend | |
if: needs.changes.outputs.frontend == 'true' && needs.changes.outputs.backend == 'true' | |
uses: organization/repository/.github/workflows/deploy-frontend.yml@main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment