Skip to content

Commit

Permalink
Rewrite build process
Browse files Browse the repository at this point in the history
- Flatten out build steps
- Add cache purging
  • Loading branch information
mayo committed Oct 3, 2024
1 parent eaed4f6 commit a34ae55
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 63 deletions.
62 changes: 56 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,60 @@ jobs:
name: website-${{ github.ref_name }}
path: public/

call-deploy-workflow:
uses: ./.github/workflows/deploy.yml
deploy:
runs-on: ubuntu-latest
needs: build
with:
artifact-name: website-${{ github.ref_name }}
secrets:
AWS_IAM_ROLE_GITHUB: ${{ secrets.AWS_IAM_ROLE_GITHUB }}
environment: ${{ github.ref_name }}
permissions:
id-token: write
steps:
- name: Download website artifact
uses: actions/download-artifact@v4
with:
name: website-${{ github.ref_name }}
path: public

- name: Download tools
run: curl -LO https://github.com/mayo/oyam.ca-tools/releases/download/v0.0.1/sync_s3-x86_64-linux.zip

- name: Extract tools
run: unzip sync_s3-x86_64-linux.zip

- name: Setup Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_IAM_ROLE_GITHUB }}
role-session-name: GitHub-Action-Role
aws-region: ${{ vars.AWS_REGION }}

- name: Upload website to S3
#run: aws s3 sync --acl public-read --delete public/ s3://${{ env.S3_BUCKET }}/
run: ./sync_s3 --bucket ${{ vars.S3_BUCKET }} -v -a public-read -d public/ | tee upload.log

- name: Save sync artifact
uses: actions/upload-artifact@v4
with:
name: sync-${{ github.ref_name }}
path: upload.log

purge-cache:
runs-on: ubuntu-latest
needs: deploy
environment: ${{ github.ref_name }}
steps:
- name: Download sync artifact
uses: actions/download-artifact@v4
with:
name: sync-${{ github.ref_name }}

- name: Download tools
run: curl -LO https://github.com/mayo/oyam.ca-tools/releases/download/v0.0.1/cf_cache-x86_64-linux.zip

- name: Extract tools
run: unzip cf_cache-x86_64-linux.zip

- name: Purge cache
env:
CF_AUTH_TOKEN: ${{ secrets.CF_AUTH_TOKEN }}
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
run: cut -d ' ' -f 2 upload.log | sed -E "s%^%https://${{ vars.DOMAIN }}/%g" | ./cf_cache purge
57 changes: 0 additions & 57 deletions .github/workflows/deploy.yml

This file was deleted.

0 comments on commit a34ae55

Please sign in to comment.