Skip to content

Commit 7da0d44

Browse files
authored
Modernize deploy workflow (vapor#942)
Switches to OIDC provider, replaces very old S3 and CloudFront actions with modern CLI usage, de-hardcodes region and S3 bucket name, unlocks pin of old version of CloudFormation deploy action, add concurrency safety.
1 parent 882b8a5 commit 7da0d44

File tree

2 files changed

+42
-51
lines changed

2 files changed

+42
-51
lines changed

.github/workflows/check.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Build docs and check cloudformation and dead links
2-
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref }}
4+
cancel-in-progress: true
35
on:
46
pull_request:
57
branches:

.github/workflows/deploy.yml

+39-50
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,49 @@
11
name: Build and deploy the Vapor documentation
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref }}
4+
cancel-in-progress: true
25
on:
36
push:
47
branches:
58
- main
9+
610
jobs:
711
deploy:
812
name: Build and deploy
913
runs-on: ubuntu-latest
14+
permissions: { id-token: write, contents: read }
15+
env: { AWS_PAGER: '' }
1016
steps:
11-
- name: Checkout repository
12-
uses: actions/checkout@v4
13-
- name: Install dependencies
14-
run: |
15-
pip install -r requirements.txt
16-
- name: Build the website
17-
run: |
18-
mkdocs build
19-
swift fixSearchIndex.swift
20-
cp googlefc012e5d94cfa05f.html site/googlefc012e5d94cfa05f.html;
21-
swift setUpRedirects.swift
22-
- name: Configure AWS credentials
23-
id: cred
24-
uses: aws-actions/configure-aws-credentials@v4
25-
with:
26-
aws-access-key-id: ${{ secrets.DOCS_DEPLOYER_AWS_ACCESS_KEY_ID }}
27-
aws-secret-access-key: ${{ secrets.DOCS_DEPLOYER_AWS_SECRET_ACCESS_KEY }}
28-
aws-region: 'eu-west-2'
29-
- name: Deploy to AWS Cloudformation
30-
id: clouddeploy
31-
if: steps.cred.outcome == 'success'
32-
uses: aws-actions/[email protected]
33-
with:
34-
name: vapor-docs-stack
35-
template: stack.yml
36-
no-fail-on-empty-changeset: "1"
37-
parameter-overrides: >-
38-
DomainName=docs.vapor.codes,
39-
S3BucketName=vapor-docs-site,
40-
AcmCertificateArn=${{ secrets.CERTIFICATE_ARN }}
41-
- name: Deploy to S3
42-
id: s3deploy
43-
if: steps.clouddeploy.outcome == 'success'
44-
uses: jakejarvis/s3-sync-action@master
45-
with:
46-
args: --acl public-read --follow-symlinks --delete
47-
env:
48-
AWS_S3_BUCKET: 'vapor-docs-site'
49-
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOYER_AWS_ACCESS_KEY_ID }}
50-
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOYER_AWS_SECRET_ACCESS_KEY }}
51-
AWS_REGION: 'eu-west-2'
52-
SOURCE_DIR: 'site'
53-
- name: Invalidate CloudFront
54-
uses: awact/cloudfront-action@master
55-
env:
56-
SOURCE_PATH: '/*'
57-
AWS_REGION: 'eu-west-2'
58-
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOYER_AWS_ACCESS_KEY_ID }}
59-
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOYER_AWS_SECRET_ACCESS_KEY }}
60-
DISTRIBUTION_ID: ${{ secrets.DOCS_DISTRIBUTION_ID }}
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Install dependencies
21+
run: pip install -r requirements.txt
22+
- name: Build the website
23+
run: |
24+
mkdocs build
25+
swift fixSearchIndex.swift
26+
cp googlefc012e5d94cfa05f.html site/googlefc012e5d94cfa05f.html
27+
swift setUpRedirects.swift
28+
29+
- name: Configure AWS credentials
30+
uses: aws-actions/configure-aws-credentials@v4
31+
with:
32+
role-to-assume: ${{ vars.OIDC_ROLE_ARN }}
33+
aws-region: ${{ vars.OIDC_ROLE_REGION }}
34+
- name: Deploy CloudFormation stack
35+
uses: aws-actions/aws-cloudformation-github-deploy@v1
36+
with:
37+
name: vapor-docs-stack
38+
template: stack.yml
39+
no-fail-on-empty-changeset: '1'
40+
parameter-overrides: >-
41+
DomainName=docs.vapor.codes,
42+
S3BucketName=${{ secrets.DOCS_S3_BUCKET_NAME }},
43+
AcmCertificateArn=${{ secrets.CERTIFICATE_ARN }}
44+
- name: Upload data to S3
45+
run: |
46+
aws s3 sync ./site 's3://${{ secrets.DOCS_S3_BUCKET_NAME }}' --no-progress --acl public-read
47+
- name: Invalidate CloudFront
48+
run: |
49+
aws cloudfront create-invalidation --distribution-id '${{ secrets.DOCS_DISTRIBUTION_ID }}' --paths '/*'

0 commit comments

Comments
 (0)