File tree Expand file tree Collapse file tree 2 files changed +56
-2
lines changed
Expand file tree Collapse file tree 2 files changed +56
-2
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy API on Version Change
2+
3+ on :
4+ push :
5+ paths :
6+ - " backend/api/package.json"
7+ - " .github/workflows/cd-api.yml"
8+
9+ jobs :
10+ deploy :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout
15+ uses : actions/checkout@v4
16+ with :
17+ fetch-depth : 2 # required so we can compare with previous commit
18+
19+ - name : Install jq
20+ run : sudo apt-get install -y jq
21+
22+ - name : Read current version
23+ id : current
24+ run : |
25+ current=$(jq -r '.version' backend/api/package.json)
26+ echo "version=$current" >> $GITHUB_OUTPUT
27+
28+ - name : Read previous version
29+ id : previous
30+ run : |
31+ # Get previous commit’s package.json (if it existed)
32+ if git show HEAD^:backend/api/package.json >/dev/null 2>&1; then
33+ previous=$(git show HEAD^:backend/api/package.json | jq -r '.version')
34+ else
35+ previous="none"
36+ fi
37+ echo "version=$previous" >> $GITHUB_OUTPUT
38+
39+ - name : Check version change
40+ id : check
41+ run : |
42+ echo "current=${{ steps.current.outputs.version }}"
43+ echo "previous=${{ steps.previous.outputs.version }}"
44+ if [ "${{ steps.current.outputs.version }}" = "${{ steps.previous.outputs.version }}" ]; then
45+ echo "changed=false" >> $GITHUB_OUTPUT
46+ else
47+ echo "changed=true" >> $GITHUB_OUTPUT
48+ fi
49+
50+ - name : Run deploy script
51+ if : steps.check.outputs.changed == 'true'
52+ run : |
53+ chmod +x backend/api/deploy-api.sh
54+ backend/api/deploy-api.sh
Original file line number Diff line number Diff line change 11{
22 "git" : {
3- "revision" : " a4a6abe " ,
4- "commitDate" : " 2025-12-04 20:36:32 +0100" ,
3+ "revision" : " af334c7 " ,
4+ "commitDate" : " 2025-12-04 20:39:20 +0100" ,
55 "author" : " MartinBraquet"
66 }
77}
You can’t perform that action at this time.
0 commit comments