-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (54 loc) · 2.01 KB
/
workbench-beta-phase.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
name: "Deploy to AWS"
on:
workflow_run:
workflows: ["01 Build and Deploy Site"]
types:
- completed
workflow_dispatch:
jobs:
preflight:
name: "Preflight Check"
runs-on: ubuntu-latest
outputs:
ok: ${{ steps.check.outputs.ok }}
folder: ${{ steps.check.outputs.folder }}
steps:
- id: check
run: |
if [[ -z "${{ secrets.DISTRIBUTION }}" || -z "${{ secrets.AWS_ACCESS_KEY_ID }}" || -z "${{ secrets.AWS_SECRET_ACCESS_KEY }}" ]]; then
echo ":information_source: No site configured" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo 'To deploy the preview on AWS, you need the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `DISTRIBUTION` secrets set up' >> $GITHUB_STEP_SUMMARY
else
echo "::set-output name=folder::"$(sed -E 's^.+/(.+)^\1^' <<< ${{ github.repository }})
echo "::set-output name=ok::true"
fi
full-build:
name: "Deploy to AWS"
needs: [preflight]
if: ${{ needs.preflight.outputs.ok }}
runs-on: ubuntu-latest
steps:
- name: "Checkout site folder"
uses: actions/checkout@v3
with:
ref: 'gh-pages'
path: 'source'
- name: "Deploy to Bucket"
uses: jakejarvis/[email protected]
with:
args: --acl public-read --follow-symlinks --delete --exclude '.git/*'
env:
AWS_S3_BUCKET: preview.carpentries.org
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: 'source'
DEST_DIR: ${{ needs.preflight.outputs.folder }}
- name: "Invalidate CloudFront"
uses: chetan/invalidate-cloudfront-action@master
env:
PATHS: /*
AWS_REGION: 'us-east-1'
DISTRIBUTION: ${{ secrets.DISTRIBUTION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}