Skip to content

Commit d458a10

Browse files
committed
ci(actions): upgrade check-origin action
- [x] upgrade `check-origin` to exit on verification failure; - [x] refactor workflows that depend on the `check-origin` action;
1 parent 3a66d82 commit d458a10

6 files changed

Lines changed: 28 additions & 29 deletions

File tree

.github/actions/check-origin/action.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ description: Checks the repository owner. The publish/deploy steps should not be
1818

1919
inputs:
2020
repo-owner:
21-
description: Repository owner
21+
description: Repository owner.
2222
required: true
2323
default: ${{ github.repository_owner }}
2424
original-owner:
25-
description: Original repository owner
25+
description: Original repository owner.
2626
required: true
2727
default: 'rfprod'
28+
bail-out:
29+
description: Exit with an error code 1 if origin verification fails.
30+
required: false
31+
default: 'true'
2832
outputs:
2933
origin:
3034
description: Indicates that the repository owner is the original owner which means that it is not a fork. Has two values - 'true' if the repo owner is the original owner, 'false' if the repo owner is not the original owner, i.e. it is a fork.
@@ -39,15 +43,18 @@ runs:
3943
run: |
4044
echo "Checking repository owner..."
4145
ORIGIN='false'
42-
if [ "$REPO_OWNER" == "$ORIGINAL_OWNER" ]; then ORIGIN='true'; fi
46+
if [[ "$REPO_OWNER" == "$ORIGINAL_OWNER" ]]; then ORIGIN='true'; fi
4347
echo "origin=$(echo ${ORIGIN})" >> $GITHUB_OUTPUT
4448
echo "### :rocket: Check origin" >> $GITHUB_STEP_SUMMARY
4549
echo "" >> $GITHUB_STEP_SUMMARY
46-
echo "| Metric | Value | " >> $GITHUB_STEP_SUMMARY
47-
echo "| ------ | ----- | " >> $GITHUB_STEP_SUMMARY
48-
echo "| REPO_OWNER | $REPO_OWNER |" >> $GITHUB_STEP_SUMMARY
50+
echo "| Metric | Value | " >> $GITHUB_STEP_SUMMARY
51+
echo "| -------------- | --------------- | " >> $GITHUB_STEP_SUMMARY
52+
echo "| REPO_OWNER | $REPO_OWNER |" >> $GITHUB_STEP_SUMMARY
4953
echo "| ORIGINAL_OWNER | $ORIGINAL_OWNER |" >> $GITHUB_STEP_SUMMARY
50-
echo "| ORIGIN | $ORIGIN |" >> $GITHUB_STEP_SUMMARY
54+
echo "| BAIL_OUT | $BAIL_OUT |" >> $GITHUB_STEP_SUMMARY
55+
echo "| ORIGIN | $ORIGIN |" >> $GITHUB_STEP_SUMMARY
56+
if [[ "$ORIGIN" == "true" && "$BAIL_OUT" == "true" ]]; then exit 1; fi
5157
env:
5258
REPO_OWNER: ${{ inputs.repo-owner }}
5359
ORIGINAL_OWNER: ${{ inputs.original-owner }}
60+
BAIL_OUT: ${{ inputs.bail.out }}

.github/workflows/build-docker.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
compodoc: true
3838
cypress: true
3939

40+
- name: Check origin
41+
uses: ./.github/actions/check-origin
42+
4043
- name: Unit test all
4144
run: |
4245
npx nx run-many --target test --all --pass-with-no-tests --code-coverage --run-in-band --ci
@@ -57,12 +60,7 @@ jobs:
5760
yarn generate:changelog
5861
yarn e2e:report || exit 1
5962
60-
- name: Check repository owner
61-
id: check-origin
62-
uses: ./.github/actions/check-origin
63-
6463
- name: Docker login
65-
if: ${{ steps.check-origin.outputs.origin == 'true' }}
6664
run: yarn docker:login "$DOCKER_REGISTRY_USER" "$DOCKER_REGISTRY_ACCESS_TOKEN"
6765
env:
6866
DOCKER_REGISTRY_USER: ${{ secrets.DOCKER_REGISTRY_USER }}
@@ -77,7 +75,7 @@ jobs:
7775
yarn docker:build documentation
7876
7977
- name: Docker push apps
80-
if: ${{ github.event.inputs.dry-run == false && steps.check-origin.outputs.origin == 'true' }}
78+
if: github.event.inputs.dry-run == false
8179
run: |
8280
yarn docker:push base
8381
yarn docker:push api-production

.github/workflows/deploy-apps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135

136136
# This job works only with a paid plan such as Blaze (https://firebase.google.com/pricing/)
137137
# - name: Deploy api
138-
# if: ${{ (fromJSON(needs.checks.outputs.changes).dependencies == 'true' || fromJSON(needs.checks.outputs.changes).src == 'true') && needs.checks.outputs.origin == 'true' }}
138+
# if: ${{ fromJSON(needs.checks.outputs.changes).dependencies == 'true' || fromJSON(needs.checks.outputs.changes).src == 'true' }}
139139
# run: |
140140
# npx nx build api --configuration firebase
141141
# yarn firebase:deploy:ci:api || exit 1

.github/workflows/publish-packages.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ jobs:
8787
runs-on: ubuntu-latest
8888

8989
outputs:
90-
origin: ${{ steps.check-origin.outputs.origin }}
9190
dry-run: ${{ steps.variables.outputs.dry-run }}
9291
ref: ${{ steps.variables.outputs.ref }}
9392
publish-client-d3-charts: ${{ steps.variables.outputs.publish-client-d3-charts }}
@@ -170,12 +169,11 @@ jobs:
170169
uses: ./.github/actions/setup-environment
171170

172171
- name: Check origin
173-
id: check-origin
174172
uses: ./.github/actions/check-origin
175173

176174
publish-client-d3-charts:
177175
needs: checks
178-
if: ${{ needs.checks.outputs.origin == 'true' && needs.checks.outputs.publish-client-d3-charts == 'true' }}
176+
if: needs.checks.outputs.publish-client-d3-charts == 'true'
179177
runs-on: ubuntu-latest
180178

181179
steps:
@@ -196,7 +194,7 @@ jobs:
196194

197195
publish-client-guided-tour:
198196
needs: checks
199-
if: ${{ needs.checks.outputs.origin == 'true' && needs.checks.outputs.publish-client-guided-tour == 'true' }}
197+
if: needs.checks.outputs.publish-client-guided-tour == 'true'
200198
runs-on: ubuntu-latest
201199

202200
steps:
@@ -217,7 +215,7 @@ jobs:
217215

218216
publish-client-pwa-offline:
219217
needs: checks
220-
if: ${{ needs.checks.outputs.origin == 'true' && needs.checks.outputs.publish-client-pwa-offline == 'true' }}
218+
if: needs.checks.outputs.publish-client-pwa-offline == 'true'
221219
runs-on: ubuntu-latest
222220

223221
steps:
@@ -238,7 +236,7 @@ jobs:
238236

239237
publish-client-util-eliza:
240238
needs: checks
241-
if: ${{ needs.checks.outputs.origin == 'true' && needs.checks.outputs.publish-client-util-eliza == 'true' }}
239+
if: needs.checks.outputs.publish-client-util-eliza == 'true'
242240
runs-on: ubuntu-latest
243241

244242
steps:
@@ -259,7 +257,7 @@ jobs:
259257

260258
publish-backend-diagnostics:
261259
needs: checks
262-
if: ${{ needs.checks.outputs.origin == 'true' && needs.checks.outputs.publish-backend-diagnostics == 'true' }}
260+
if: needs.checks.outputs.publish-backend-diagnostics == 'true'
263261
runs-on: ubuntu-latest
264262

265263
steps:

.github/workflows/trunk.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
outputs:
2222
changes: ${{ steps.check-changes.outputs.changes }}
2323
deploy: ${{ steps.check-changes.outputs.deploy }}
24-
origin: ${{ steps.check-origin.outputs.origin }}
2524

2625
steps:
2726
- name: Checkout sources
@@ -37,7 +36,6 @@ jobs:
3736
uses: ./.github/actions/check-changes
3837

3938
- name: Check origin
40-
id: check-origin
4139
uses: ./.github/actions/check-origin
4240

4341
trunk:
@@ -106,7 +104,7 @@ jobs:
106104
uses: ./.github/actions/dist-artifact-upload
107105

108106
- name: Dispatch package publishing
109-
if: ${{ needs.checks.outputs.origin == 'true' && fromJSON(needs.checks.outputs.changes).packages == 'true' }}
107+
if: fromJSON(needs.checks.outputs.changes).packages == 'true'
110108
env:
111109
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112110
REPO: ${{ github.repository }}
@@ -127,7 +125,7 @@ jobs:
127125

128126
deploy-apps:
129127
needs: [checks, trunk]
130-
if: ${{ needs.checks.outputs.origin == 'true' && fromJSON(needs.checks.outputs.changes).deploy == 'true' }}
128+
if: fromJSON(needs.checks.outputs.changes).deploy == 'true'
131129
uses: ./.github/workflows/deploy-apps.yml
132130
secrets: inherit
133131
with:
@@ -138,7 +136,7 @@ jobs:
138136

139137
publish-packages:
140138
needs: [checks, trunk]
141-
if: ${{ needs.checks.outputs.origin == 'true' && fromJSON(needs.checks.outputs.changes).packages == 'true' }}
139+
if: fromJSON(needs.checks.outputs.changes).packages == 'true'
142140
runs-on: ubuntu-latest
143141

144142
permissions:

.github/workflows/validate-pr.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
projects-build: ${{ steps.check-projects-build.outputs.projects }}
2424
changes: ${{ steps.check-changes.outputs.changes }}
2525
success: ${{ steps.check.outputs.success || 'true' }}
26-
origin: ${{ steps.check-origin.outputs.origin }}
2726

2827
steps:
2928
- name: Checkout sources
@@ -70,7 +69,6 @@ jobs:
7069
trunk: 'main'
7170

7271
- name: Check origin
73-
id: check-origin
7472
uses: ./.github/actions/check-origin
7573

7674
- name: Set failure
@@ -272,7 +270,7 @@ jobs:
272270

273271
publish-packages-dry-run:
274272
needs: checks
275-
if: ${{ needs.checks.outputs.origin == 'true' && fromJSON(needs.checks.outputs.changes).packages == 'true' }}
273+
if: fromJSON(needs.checks.outputs.changes).packages == 'true'
276274
runs-on: ubuntu-latest
277275

278276
permissions:

0 commit comments

Comments
 (0)