11---
2- # This workflow will do a clean install of node dependencies and deploy to AWS.
2+ # Staging Deploy Workflow
3+ #
4+ # Triggered on: pull requests targeting main
5+ # Jobs:
6+ # - test: Lints and runs unit tests
7+ # - build: Builds the site with a PR-specific base URL and uploads artifacts
8+ # - a11y: Runs accessibility tests against the root build
9+ # - deploy: Syncs build to S3, invalidates CloudFront cache, and comments the staging URL on the PR
310
411name : Staging Deploy
512run-name : Publish staging site
916 branches : [ main ]
1017
1118permissions :
12- id-token : write # required to use OIDC authentication
1319 contents : read # required to checkout the code from the repo
14- pull-requests : write # required to comment on the PR with the staging URL
20+
21+ concurrency :
22+ group : staging-${{ github.event.pull_request.number }}
23+ cancel-in-progress : true
1524
1625jobs :
1726 test :
1827 name : Test
1928 runs-on : ubuntu-latest
29+ permissions :
30+ contents : read
2031
2132 steps :
2233 - name : Checkout
23- uses : actions/checkout@v6
34+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
35+ with :
36+ persist-credentials : false
2437
2538 - name : Set up Node.js
26- uses : actions/setup-node@v6
39+ uses : actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
2740 with :
2841 node-version-file : package.json
2942
@@ -42,13 +55,17 @@ jobs:
4255 build :
4356 name : Build
4457 runs-on : ubuntu-latest
58+ permissions :
59+ contents : read
4560
4661 steps :
4762 - name : Checkout
48- uses : actions/checkout@v6
63+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
64+ with :
65+ persist-credentials : false
4966
5067 - name : Set up Node.js
51- uses : actions/setup-node@v6
68+ uses : actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
5269 with :
5370 node-version-file : package.json
5471
6784 BASEURL : ${{ github.event.repository.name }}/pr/${{ github.event.number }}
6885
6986 - name : Upload artifacts
70- uses : actions/upload-artifact@v7
87+ uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
7188 with :
7289 name : build-artifact
7390 path : out
@@ -76,15 +93,19 @@ jobs:
7693 a11y :
7794 name : Accessibility
7895 runs-on : ubuntu-latest
96+ permissions :
97+ contents : read
7998 # No basePath — built at root so the local test server can resolve assets
8099 # The deployment build (with BASEURL) is tested separately via the build job
81100
82101 steps :
83102 - name : Checkout
84- uses : actions/checkout@v6
103+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
104+ with :
105+ persist-credentials : false
85106
86107 - name : Set up Node.js
87- uses : actions/setup-node@v6
108+ uses : actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
88109 with :
89110 node-version-file : package.json
90111
@@ -107,33 +128,46 @@ jobs:
107128 name : Deploy
108129 runs-on : ubuntu-slim
109130 needs : [test, build, a11y]
131+ permissions :
132+ id-token : write # required to use OIDC authentication
133+ contents : read
134+ pull-requests : write # required to comment on the PR with the staging URL
110135 environment :
111136 name : staging
112137 url : ${{ steps.deploy_url.outputs.url }}
113138
114139 steps :
115140 - name : Set deploy URL
116141 id : deploy_url
117- run : echo "url=https://staging.overturemaps.org/${{ github.event.repository.name }}/pr/${{ github.event.number }}/index.html" >> $GITHUB_OUTPUT
142+ run : echo "url=https://staging.overturemaps.org/${GITHUB_EVENT_REPOSITORY_NAME}/pr/${PR_NUMBER}/index.html" >> $GITHUB_OUTPUT
143+ env :
144+ GITHUB_EVENT_REPOSITORY_NAME : ${{ github.event.repository.name }}
145+ PR_NUMBER : ${{ github.event.number }}
118146
119147 - name : Configure AWS credentials
120- uses : aws-actions/configure-aws-credentials@v6
148+ uses : aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
121149 with :
122150 role-to-assume : arn:aws:iam::763944545891:role/pages-staging-oidc-overturemaps
123151 aws-region : us-west-2
124152
125153 - name : Download artifacts
126- uses : actions/download-artifact@v8
154+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
127155 with :
128156 name : build-artifact
129157 path : build
130158
131159 - name : Copy to S3
132160 run : |
133- aws s3 sync --delete build s3://overture-managed-staging-usw2/gh-pages/${{ github.event.repository.name }}/pr/${{ github.event.number }}/
161+ aws s3 sync --delete build s3://overture-managed-staging-usw2/gh-pages/${GITHUB_EVENT_REPOSITORY_NAME}/pr/${PR_NUMBER}/
162+ env :
163+ GITHUB_EVENT_REPOSITORY_NAME : ${{ github.event.repository.name }}
164+ PR_NUMBER : ${{ github.event.number }}
134165
135166 - name : Bust the Cache
136- run : aws cloudfront create-invalidation --distribution-id E1KP2IN0H2RGGT --paths "/${{ github.event.repository.name }}/pr/${{ github.event.number }}/*"
167+ run : aws cloudfront create-invalidation --distribution-id E1KP2IN0H2RGGT --paths "/${GITHUB_EVENT_REPOSITORY_NAME}/pr/${PR_NUMBER}/*"
168+ env :
169+ GITHUB_EVENT_REPOSITORY_NAME : ${{ github.event.repository.name }}
170+ PR_NUMBER : ${{ github.event.number }}
137171
138172 - name : Get deploy timestamp
139173 id : timestamp
0 commit comments