Skip to content

Commit

Permalink
Merge pull request #107 from smlt/main
Browse files Browse the repository at this point in the history
Update deploy workflow to use DigitalOcean Spaces.
  • Loading branch information
emmiegit authored Aug 6, 2024
2 parents 9bc309b + 3bcd908 commit d3cf1bf
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ jobs:
name: Deploy CSS
runs-on: ubuntu-latest

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Checkout
uses: actions/checkout@v1
Expand All @@ -23,29 +31,33 @@ jobs:
- name: Build
run: ./build.sh

- name: Deploy (GitHub Pages)
uses: JamesIves/github-pages-[email protected]
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
branch: gh-pages
folder: dist
path: dist/

- name: Deploy (S3)
uses: emmiegit/s3-sync-action@main
with:
args: --delete
- name: Deploy (GitHub Pages)
uses: actions/deploy-pages@v4
id: deployment

- name: Upload to S3
run: |
export sync_args=( "--delete" "--acl" "public-read" "dist" "s3://${{ vars.AWS_S3_BUCKET }}/${{ env.BUCKET_PATH }}" )
# Manually set content-types for anything aws-cli can't guess correctly
aws s3 sync ${sync_args[@]} --exclude "*" --include "*.css" --content-type "text/css; charset=utf-8"
aws s3 sync ${sync_args[@]} --exclude "*.css"
env:
AWS_S3_BUCKET: ${{ vars.AWS_S3_BUCKET }}
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: dist
DEST_DIR: ${{ env.BUCKET_PATH }}
AWS_ENDPOINT_URL: 'https://${{ vars.DIGITALOCEAN_SPACES_REGION }}.digitaloceanspaces.com'
AWS_DEFAULT_REGION: 'us-east-1'

- name: Invalidate CloudFront
uses: chetan/invalidate-cloudfront-action@v2
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}

- name: Invalidate Spaces Cache
run: doctl compute cdn flush $DIGITALOCEAN_CDN_ID
env:
DISTRIBUTION: ${{ secrets.CF_DISTRIBUTION }}
PATHS: /${{ env.BUCKET_PATH }}/ /${{ env.BUCKET_PATH }}/*
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DIGITALOCEAN_CDN_ID: ${{ vars.DIGITALOCEAN_CDN_ID }}

0 comments on commit d3cf1bf

Please sign in to comment.