-
Notifications
You must be signed in to change notification settings - Fork 2
47 lines (40 loc) · 1.38 KB
/
cd.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
name: "CD: Deploy site"
# Check out https://help.github.com/en/articles/workflow-syntax-for-github-actions for documentation on Actions.
on:
workflow_dispatch:
release:
types: [released]
concurrency: production
defaults:
run:
shell: bash # Set the default shell to bash.
jobs:
cd:
runs-on: ubuntu-latest
environment:
name: production
url: https://codetalk.io
steps:
- uses: actions/checkout@v3
- name: Download latest release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download --pattern "_site.tar.gz" --dir ./
tar -zxvf _site.tar.gz
- name: Upload site to S3
env:
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 sync _site s3://codetalk.io --delete
- name: Purge CloudFront cache
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
run: |
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE}/purge_cache" \
-H "Authorization: Bearer ${CLOUDFLARE_TOKEN}" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'