updated events 8-23(#17) #42
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: Deploy Jekyll site to AWS Dev | |
on: | |
push: | |
branches: ["main"] | |
workflow_dispatch: | |
inputs: | |
invalidate-cache: | |
description: "Invalidate CloudFront cache" | |
required: true | |
type: boolean | |
default: false | |
permissions: | |
contents: read | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "aws-dev" | |
cancel-in-progress: false | |
jobs: | |
# Build job | |
deploy: | |
runs-on: ubuntu-latest | |
environment: | |
name: development | |
url: https://oscalio.dev | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 | |
with: | |
ruby-version: '3.1' | |
bundler-cache: true | |
cache-version: 0 | |
- name: Build with Jekyll | |
run: bundle exec jekyll build | |
env: | |
JEKYLL_ENV: development | |
- name: Add robots.txt file to disallow all | |
run: | | |
echo -e "User-agent: *\nDisallow: /" > _site/robots.txt | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: oscalio-content-dev | |
path: _site/ | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.ROLE_ARN }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Copy files to the dev environment | |
run: | | |
aws s3 sync . s3://${{ secrets.S3_BUCKET_NAME }} | |
working-directory: _site | |
- name: Invalidate CloudFront cache | |
if: ${{ inputs.invalidate-cache }} | |
run: | | |
aws cloudfront create-invalidation --distribution-id ${{ vars.DISTRIBUTION_ID }} --paths "/*" |