CD: Deploy site #124
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}' |