-
Notifications
You must be signed in to change notification settings - Fork 28
56 lines (50 loc) · 1.6 KB
/
main.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
name: CI/CD Pipeline
on:
push:
branches:
- main
pull_request:
branches: [main]
release:
types: [published]
permissions:
contents: write
packages: write
jobs:
determine_version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
is_pr: ${{ steps.set_version.outputs.is_pr }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set version and PR flag
id: set_version
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "version=$(git rev-parse --short ${{ github.event.pull_request.head.sha }} | cut -c 1-7)" >> $GITHUB_OUTPUT
echo "is_pr=true" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "push" ]]; then
echo "version=latest" >> $GITHUB_OUTPUT
echo "is_pr=false" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "release" ]]; then
echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
echo "is_pr=false" >> $GITHUB_OUTPUT
fi
frontend:
needs: determine_version
uses: ./.github/workflows/frontend.yml
with:
version: ${{ needs.determine_version.outputs.version }}
is_pr: ${{ needs.determine_version.outputs.is_pr }}
secrets: inherit
backend:
needs: determine_version
uses: ./.github/workflows/backend.yml
with:
version: ${{ needs.determine_version.outputs.version }}
is_pr: ${{ needs.determine_version.outputs.is_pr }}
secrets: inherit