name: CI/CD
on:
push:
branches:
main
pull_request:
env:
CI: 1
jobs:
preflight:
runs-on: ubuntu-latest
name: Preflight checks
outputs:
be_changed: ${{ steps.be-changes.outputs.be_changed }}
fe_changed: ${{ steps.fe-changes.outputs.fe_changed }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Change check (frontend)
id: fe-changes
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ] | [ -n "$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./.github)" ]
then
echo "fe_changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./frontend
if [ -n "$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./frontend)" ]
- name: Change check (backend)
id: be-changes
echo "be_changed=true" >> "$GITHUB_OUTPUT"
git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./backend
if [ -n "$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./backend)" ]
backend:
uses: ./.github/workflows/backend-pipeline.yml
needs: preflight
if: needs.preflight.outputs.be_changed == 'true'
frontend:
uses: ./.github/workflows/frontend-pipeline.yml
if: needs.preflight.outputs.fe_changed == 'true'