This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
rotini/.github/workflows/ci.yml
Marc Cataford 62cb0955d5
fix: trigger ci run if taskfile changes + split basepath env variable… (#27)
fix: trigger ci run if taskfile changes + split basepath env variables in taskfile
2023-08-19 11:33:18 -04:00

107 lines
3 KiB
YAML

name: CI/CD
on:
push:
branches:
main
pull_request:
env:
CI: 1
TASK_VERSION: "3.28.0"
jobs:
preflight:
runs-on: ubuntu-latest
name: Preflight checks
outputs:
be_changed: ${{ steps.change-check.outputs.be_changed }}
fe_changed: ${{ steps.change-check.outputs.fe_changed }}
task_version: ${{ env.TASK_VERSION }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Change check
id: change-check
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]
then
echo "fe_changed=true" >> "$GITHUB_OUTPUT"
echo "be_changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ -n "$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./.github ./Taskfile*.yml)" ]
then
echo "fe_changed=true" >> "$GITHUB_OUTPUT"
echo "be_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)" ]
then
echo "fe_changed=true" >> "$GITHUB_OUTPUT"
else
echo "fe_changed=false" >> "$GITHUB_OUTPUT"
fi
if [ -n "$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} -- ./backend)" ]
then
echo "be_changed=true" >> "$GITHUB_OUTPUT"
else
echo "be_changed=false" >> "$GITHUB_OUTPUT"
fi
backend:
uses: ./.github/workflows/backend-pipeline.yml
with:
task-version: ${{ needs.preflight.outputs.task_version }}
needs: preflight
if: needs.preflight.outputs.be_changed == 'true'
frontend:
uses: ./.github/workflows/frontend-pipeline.yml
with:
task-version: ${{ needs.preflight.outputs.task_version }}
needs: preflight
if: needs.preflight.outputs.fe_changed == 'true'
frontend-ok:
name: Frontend Pipeline Success
runs-on: ubuntu-latest
needs: [frontend, preflight]
if: |
always()
&& (
needs.frontend.outputs.pipeline-success == 'true'
|| needs.preflight.outputs.fe_changed == 'false'
)
steps:
- run: |
if [ "${{ needs.preflight.outputs.fe_changed }}" == "false" ]
then
exit 0
fi
if [ "${{ needs.frontend.outputs.pipeline-success }}" == "true" ]
then
exit 0
fi
exit 1
backend-ok:
name: Backend Pipeline Success
runs-on: ubuntu-latest
needs: [backend, preflight]
if: |
always()
&& (
needs.backend.outputs.pipeline-success == 'true'
|| needs.preflight.outputs.be_changed == 'false'
)
steps:
- run: |
if [ "${{ needs.preflight.outputs.be_changed }}" == "false" ]
then
exit 0
fi
if [ "${{ needs.backend.outputs.pipeline-success }}" == "true" ]
then
exit 0
fi
exit 1