-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (87 loc) · 2.9 KB
/
shared-ext-update-static-files-workflow.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Shared Update Static Files Workflow
on:
workflow_call:
inputs:
commontoolingBranch:
description: 'Commontooling branch or tag to use'
required: true
default: 'main'
type: string
secrets:
WRITE_ACCESS_DEPLOY_KEY:
description: 'A deploy key that is used to checkout code with write access'
required: true
COMMONTOOLING_DEPLOY_KEY:
description: 'A deploy key that is used to fetch Commontooling'
required: true
AWS_ACCOUNT_ID:
description: 'An AWS Account ID, used to access ECR'
required: true
env:
COMMONTOOLING_BRANCH: ${{ inputs.commontoolingBranch == '' && 'main' || inputs.commontoolingBranch }}
jobs:
UpdateStaticFiles:
permissions:
contents: read
id-token: write
runs-on: ubuntu-22.04
environment:
name: update-static-files
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 1
ssh-key: ${{ secrets.WRITE_ACCESS_DEPLOY_KEY }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/gha_ecr_public_read
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
mask-password: true
- name: Initialise commontooling
uses: actions/checkout@v4
with:
repository: bbc/rd-cloudfit-commontooling
ref: ${{ env.COMMONTOOLING_BRANCH }}
path: commontooling
fetch-depth: 1
ssh-key: ${{ secrets.COMMONTOOLING_DEPLOY_KEY }}
- name: Configure git user info
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
- name: Update static files
run: |
make static-files
- name: Show git status
run: |
git status
- name: Commit static file changes
id: commitStaticFileChanges
run: |
git add .
if git commit -a -m "Regenerate static files"
then
echo "haveChanges=true" >> $GITHUB_OUTPUT;
else
echo "haveChanges=false" >> $GITHUB_OUTPUT;
fi
- name: Push static file changes
if: ${{ steps.commitStaticFileChanges.outputs.haveChanges == 'true' }}
run: |
git push
- name: Adding summary
run: |
if [ '${{ steps.commitStaticFileChanges.outputs.haveChanges }}' == 'true' ]
then
echo "The static files have been updated" >> $GITHUB_STEP_SUMMARY
else
echo "There are no static file updates" >> $GITHUB_STEP_SUMMARY
fi