-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from smlt/main
Update deploy workflow to use DigitalOcean Spaces.
- Loading branch information
Showing
1 changed file
with
31 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 }} |