Skip to content

Commit

Permalink
Merge pull request #11 from carpentries-incubator/update-workflows-ve…
Browse files Browse the repository at this point in the history
…rsion-0.9.5

Update Workflows to Version 0.9.5
  • Loading branch information
jsteyn authored Jun 16, 2023
2 parents 130edb0 + e67df61 commit d752141
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ and invalidate the failing cache](https://github.blog/changelog/2022-10-20-manag
or by setting the `CACHE_VERSION` secret to the current date (which will
invalidate all of the caches).

### Deploy to AWS (deploy-aws.yaml)

If you have an AWS bucket that is set up to deploy the site from a folder, this
workflow will deploy the site to that folder after `01 Build and Deploy` runs.
It can also be triggered manually.

Note: for this to work, you must have the `AWS_S3_BUCKET`, `AWS_ACCESS_KEY_ID`,
and `AWS_SECRET_ACCESS_KEY` in your repository secrets. If any of these are
missing, the workflow will not run.

## Updates

### Setup Information
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/deploy-aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "Deploy to AWS"

on:
workflow_run:
workflows: ["01 Build and Deploy Site"]
types:
- completed
workflow_dispatch:

jobs:
preflight:
name: "Preflight Check"
runs-on: ubuntu-latest
outputs:
ok: ${{ steps.check.outputs.ok }}
folder: ${{ steps.check.outputs.folder }}
steps:
- id: check
run: |
if [[ -z "${{ secrets.AWS_S3_BUCKET }}" || -z "${{ secrets.AWS_ACCESS_KEY_ID }}" || -z "${{ secrets.AWS_SECRET_ACCESS_KEY }}" ]]; then
echo ":information_source: No site configured" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "To deploy on AWS, you need the `AWS_S3_BUCKET`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY` secrets set up" >> $GITHUB_STEP_SUMMARY
else
echo "::set-output name=folder::"$(sed -E 's^.+/(.+)^\1^' <<< ${{ github.repository }})
echo "::set-output name=ok::true"
fi
full-build:
name: "Deploy to AWS"
needs: [preflight]
if: ${{ needs.preflight.outputs.ok }}
runs-on: ubuntu-latest
steps:

- name: "Checkout site folder"
uses: actions/checkout@v3
with:
ref: 'gh-pages'
path: 'source'

- name: "Deploy to Bucket"
uses: jakejarvis/[email protected]
with:
args: --acl public-read --follow-symlinks --delete --exclude '.git/*'
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: 'source'
DEST_DIR: ${{ needs.preflight.outputs.folder }}

- name: "Invalidate CloudFront"
uses: chetan/invalidate-cloudfront-action@master
env:
PATHS: /*
AWS_REGION: 'us-east-1'
DISTRIBUTION: ${{ secrets.DISTRIBUTION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/sandpaper-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.3
0.12.3

0 comments on commit d752141

Please sign in to comment.