44 workflow_dispatch :
55 inputs :
66 merge :
7- description : Merge staging into master first? (y/N)
7+ type : boolean
8+ description : Merge staging into master first?
89 required : false
9- default : ' n'
10+ default : false
11+ ignore_metadata_diff :
12+ type : boolean
13+ description : Perform all jobs, regardless of whether there are actual changes?
14+ required : false
15+ default : false
1016
1117concurrency :
1218 group : cd-${{ github.ref_name }}
1319
1420env :
1521 PROJECT_NAME : amber-api
16- SENTRY_ORG : csvalpha
17- APP_ID : 152333
1822
1923jobs :
2024 branch_check :
2327 steps :
2428 - name : Validate branch
2529 run : |
26- if [ $GITHUB_REF_NAME != 'staging' ] && [ $GITHUB_REF_NAME != 'master' ]; then
30+ if [ " $GITHUB_REF_NAME" != 'staging' ] && [ " $GITHUB_REF_NAME" != 'master' ]; then
2731 echo 'This workflow can only be run on branches staging and master.'
2832 exit 1
2933 fi
@@ -37,41 +41,41 @@ jobs:
3741 stage : ${{ steps.get_metadata.outputs.stage }}
3842 steps :
3943 - name : Checkout code
40- uses : actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # tag=v2.4.0
44+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4145
4246 - name : Get metadata
4347 id : get_metadata
4448 env :
45- INPUT_MERGE : ${{ github.event. inputs.merge }}
49+ INPUT_MERGE : ${{ inputs.merge }}
4650 run : |
47- if [ $GITHUB_REF_NAME = 'master' ]; then
48- if [ "${ INPUT_MERGE,,} " = 'y ' ]; then
51+ if [ " $GITHUB_REF_NAME" = 'master' ]; then
52+ if [ "$INPUT_MERGE" == 'true ' ]; then
4953 git fetch origin staging
5054 if ! git diff origin/master origin/staging --exit-code; then
51- echo '::set-output name= has_diff:: true'
55+ echo 'has_diff= true' >> "$GITHUB_OUTPUT"
5256 else
53- echo '::set-output name= has_diff:: false'
57+ echo 'has_diff= false' >> "$GITHUB_OUTPUT"
5458 fi
5559 fi
5660
57- echo '::set-output name= stage:: production'
61+ echo 'stage= production' >> "$GITHUB_OUTPUT"
5862 else
59- echo '::set-output name= stage:: staging'
63+ echo 'stage= staging' >> "$GITHUB_OUTPUT"
6064 fi
6165
6266 merge :
6367 name : Merge
6468 runs-on : ubuntu-latest
6569 needs : metadata
66- if : github.event. inputs.merge == 'y'
70+ if : inputs.merge
6771 outputs :
6872 sha : ${{ steps.get_sha.outputs.sha }}
6973 steps :
7074 - name : Validate inputs
7175 env :
7276 HAS_DIFF : ${{ fromJSON(needs.metadata.outputs.has_diff || false) }}
7377 run : |
74- if [ $GITHUB_REF_NAME != 'master' ]; then
78+ if [ " $GITHUB_REF_NAME" != 'master' ]; then
7579 echo 'Can only merge when the workflow target branch is master.'
7680 exit 1
7781 fi
@@ -82,11 +86,11 @@ jobs:
8286
8387 - name : Checkout code
8488 if : fromJSON(needs.metadata.outputs.has_diff)
85- uses : actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # tag=v2.4.0
89+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
8690
8791 - name : Run merge
88- if : fromJSON(needs.metadata.outputs.has_diff)
89- uses : devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f # tag= v1.4.0
92+ if : fromJSON(needs.metadata.outputs.has_diff) || inputs.ignore_metadata_diff
93+ uses : devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f # v1.4.0
9094 with :
9195 type : now
9296 from_branch : staging
@@ -95,26 +99,27 @@ jobs:
9599
96100 - name : Get merge commit SHA
97101 id : get_sha
98- if : fromJSON(needs.metadata.outputs.has_diff)
102+ if : fromJSON(needs.metadata.outputs.has_diff) || inputs.ignore_metadata_diff
99103 run : |
100104 git fetch origin master
101- echo '::set-output name= sha::' $(git rev-parse origin/master)
105+ echo 'sha='" $(git rev-parse origin/master)" >> "$GITHUB_OUTPUT"
102106
103107 continuous_integration :
104108 name : Continuous Integration
105109 needs : [metadata, merge]
106- if : fromJSON(needs.metadata.outputs.has_diff)
107- uses : csvalpha/amber-api/ .github/workflows/continuous-integration.yml@staging
110+ if : fromJSON(needs.metadata.outputs.has_diff) || inputs.ignore_metadata_diff
111+ uses : ./ .github/workflows/continuous-integration.yml
108112 with :
109113 sha : ${{ needs.merge.outputs.sha }}
110114 secrets :
115+ codecov_token : ${{ secrets.CODECOV_TOKEN }}
111116 rails_master_key : ${{ secrets.RAILS_MASTER_KEY }}
112117
113118 publish_image :
114119 name : Publish Image
115120 needs : [metadata, merge]
116- if : fromJSON(needs.metadata.outputs.has_diff)
117- uses : csvalpha/amber-api/ .github/workflows/publish-image.yml@staging
121+ if : fromJSON(needs.metadata.outputs.has_diff) || inputs.ignore_metadata_diff
122+ uses : ./ .github/workflows/publish-image.yml
118123 with :
119124 sha : ${{ needs.merge.outputs.sha }}
120125 secrets :
@@ -126,37 +131,36 @@ jobs:
126131 needs : [metadata, merge, continuous_integration, publish_image]
127132 if : |
128133 (github.ref_name == 'staging' || github.ref_name == 'master') && ((github.ref_name == 'master' &&
129- github.event. inputs.merge == 'y' && fromJSON(needs.metadata.outputs.has_diff) && success()) ||
130- ((github.event. inputs.merge != 'y' || !fromJSON(needs.metadata.outputs.has_diff)) && !cancelled()))
134+ inputs.merge && ( fromJSON(needs.metadata.outputs.has_diff) || inputs.ignore_metadata_diff ) && success()) ||
135+ ((! inputs.merge || !( fromJSON(needs.metadata.outputs.has_diff) || inputs.ignore_metadata_diff )) && !cancelled()))
131136 steps :
132137 - name : Get environment URL
133138 id : get_url
134139 run : |
135- if [ $GITHUB_REF_NAME = 'master' ]; then
136- echo '::set-output name= environment_url:: https://csvalpha.nl/api'
140+ if [ " $GITHUB_REF_NAME" = 'master' ]; then
141+ echo 'environment_url= https://csvalpha.nl/api' >> "$GITHUB_OUTPUT"
137142 else
138- echo '::set-output name= environment_url:: https://staging.csvalpha.nl/api'
143+ echo 'environment_url= https://staging.csvalpha.nl/api' >> "$GITHUB_OUTPUT"
139144 fi
140145
141146 - name : Checkout code
142- uses : actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # tag=v2.4.0
147+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
143148 with :
144149 ref : ${{ needs.merge.outputs.sha }}
145150
146151 - name : Start deployment
147- uses : bobheadxi/deployments@f235d02c2daaaa84c710d013c7d39f7f0f8bf298 # tag=v0.6.2
152+ uses : bobheadxi/deployments@648679e8e4915b27893bd7dbc35cb504dc915bc8 # v1.5.0
148153 id : start_deployment
149154 with :
150155 step : start
151- token : ${{ secrets.GITHUB_TOKEN }}
152156 env : ${{ needs.metadata.outputs.stage }}
153157
154158 - name : Deploy
155- uses : appleboy/ssh-action@1d1b21ca96111b1eb4c03c21c14ebb971d2200f6 # tag=v0.1.4
159+ uses : appleboy/ssh-action@8faa84277b88b6cd1455986f459aa66cf72bc8a3 # v1.2.1
156160 env :
157161 STAGE : ${{ needs.metadata.outputs.stage }}
158162 with :
159- host : csvalpha.nl
163+ host : ssh. csvalpha.nl
160164 username : github-actions
161165 key : ${{ secrets.SSH_PRIVATE_KEY }}
162166 envs : PROJECT_NAME,STAGE
@@ -167,50 +171,60 @@ jobs:
167171 docker-compose up -d
168172
169173 - name : Finalize Sentry release
170- uses : getsentry/action-release@744e4b262278339b79fb39c8922efcae71e98e39 # tag= v1.1.6
174+ uses : getsentry/action-release@a74facf8a080ecbdf1cb355f16743530d712abb7 # v1.11.0
171175 env :
172176 SENTRY_AUTH_TOKEN : ${{ secrets.SENTRY_AUTH_TOKEN }}
177+ SENTRY_ORG : ${{ vars.SENTRY_ORG_NAME }}
173178 SENTRY_PROJECT : ${{ env.PROJECT_NAME }}
174179 with :
175180 environment : ${{ needs.metadata.outputs.stage }}
176181 version : ${{ needs.merge.outputs.sha }}
177182 set_commits : skip
178183
179184 - name : Finish deployment
180- uses : bobheadxi/deployments@f235d02c2daaaa84c710d013c7d39f7f0f8bf298 # tag=v0.6.2
185+ uses : bobheadxi/deployments@648679e8e4915b27893bd7dbc35cb504dc915bc8 # v1.5.0
181186 if : steps.start_deployment.conclusion == 'success' && always()
182187 with :
183188 step : finish
184- token : ${{ secrets.GITHUB_TOKEN }}
185189 status : ${{ job.status }}
186190 deployment_id : ${{ steps.start_deployment.outputs.deployment_id }}
191+ env : ${{ needs.metadata.outputs.stage }}
187192 env_url : ${{ steps.get_url.outputs.environment_url }}
188193
189194 update_check_run :
190195 name : Update Check Run
191196 runs-on : ubuntu-latest
192- needs : [branch_check, metadata, merge, continuous_integration, publish_image, deploy]
197+ needs :
198+ [
199+ branch_check,
200+ metadata,
201+ merge,
202+ continuous_integration,
203+ publish_image,
204+ deploy,
205+ ]
193206 if : (github.ref_name == 'staging' || github.ref_name == 'master') && always()
207+ permissions :
208+ checks : write
194209 steps :
195210 - name : Get conclusion
196211 id : get_conclusion
197212 env :
198213 RESULTS : ${{ join(needs.*.result, ' ') }}
199214 run : |
200- echo '::set-output name= conclusion:: success'
215+ echo 'conclusion= success' >> "$GITHUB_OUTPUT"
201216 for RESULT in $RESULTS; do
202- if [ $RESULT = 'cancelled' ] || [ $RESULT = 'failure' ]; then
203- echo '::set-output name= conclusion::' $RESULT
217+ if [ " $RESULT" = 'cancelled' ] || [ " $RESULT" = 'failure' ]; then
218+ echo 'conclusion='" $RESULT" >> "$GITHUB_OUTPUT"
204219 break
205220 fi
206221 done
207222
208223 - name : Update Continuous Delivery check run
209- uses : guidojw/actions/update-check-run@2b1dea8cbd9e44491c269e771b75636026caf8ca # tag=v1.1 .0
224+ uses : LouisBrunner/checks-action@6b626ffbad7cc56fd58627f774b9067e6118af23 # v2.0 .0
210225 with :
211- app_id : ${{ env.APP_ID }}
212- private_key : ${{ secrets.APP_PRIVATE_KEY }}
213226 sha : ${{ needs.merge.outputs.sha }}
227+ token : ${{ github.token }}
214228 name : Continuous Delivery
215229 conclusion : ${{ steps.get_conclusion.outputs.conclusion }}
216230 details_url : ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
0 commit comments