This repository has been archived by the owner on May 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (103 loc) · 3.04 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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@v4
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