Skip to content

Commit 20d4063

Browse files
authored
gha: rerun workflow after AWS creds injected (#35)
in the circleCI pipeline it does not run until makefile sets up webhooks but in GHA it runs as soon as zero create pushes the repo, during that time it has no AWS credentials, so it will always fail
1 parent cfb7aff commit 20d4063

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

scripts/gha-setup.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,12 @@ curl -XPUT "https://api.github.com/repos/$GITHUB_ORG/$GITHUB_REPO/branches/$DEFA
3939
"restrictions": null
4040
}'
4141

42+
## Rerun github actions workflow, since the first time github action is ran there are no AWS credentials
43+
## so it will always fail, begining of this script we inject the AWS credentials, therefore now we can rerun the workflow
44+
MOST_RECENT_RUN_ID=$(curl -XGET --url "https://api.github.com/repos/${GITHUB_ORG}/${GITHUB_REPO}/actions/runs" \
45+
--header "Authorization: token $GITHUB_ACCESS_TOKEN" --header 'Content-Type: application/json' | jq -r ".workflow_runs[0].id")
46+
## Triggering the rerun
47+
curl -XPOST --url "https://api.github.com/repos/${GITHUB_ORG}/${GITHUB_REPO}/actions/runs/${MOST_RECENT_RUN_ID}/rerun" \
48+
--header "Authorization: token $GITHUB_ACCESS_TOKEN" --header 'Content-Type: application/json'
49+
4250
echo "Github actions environment variables setup successfully."

templates/.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
env:
99
CI: true
10-
build_env: production
10+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
1111
steps:
1212
- uses: actions/checkout@v2
1313
- name: Run Unit Tests
@@ -17,6 +17,10 @@ jobs:
1717
- run: |
1818
yarn
1919
yarn test --watchAll=false
20+
- if: env.AWS_ACCESS_KEY_ID == null
21+
run: |
22+
echo "AWS Credentials not found, This is expected for the first run as the repo is provisioned then secrets are injected at a later step."
23+
exit 1
2024
build:
2125
needs: unit-test
2226
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)