chriswachira triggered a Hugo site deployment #37
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 website changes to production S3 bucket | |
run-name: ${{ github.actor }} triggered a Hugo site deployment | |
on: | |
push: | |
branches: | |
- "main" | |
jobs: | |
publish-site: | |
name: "Publish site to S3 bucket" | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Hugo & other CI dependencies | |
run: | | |
sudo apt install wget | |
wget https://github.com/gohugoio/hugo/releases/download/v0.120.1/hugo_0.120.1_linux-amd64.deb | |
sudo dpkg -i hugo_0.120.1_linux-amd64.deb | |
- name: Install AWS CLI | |
run: sudo snap install aws-cli --classic | |
- name: Generate public directory | |
run: | | |
hugo --baseURL ${{ vars.SITE_BASE_URL }} --logLevel debug | |
du -sh public/ | |
- name: Push public directory contents to S3 bucket | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
run: aws s3 cp --recursive public/ s3://chriswachira-com | |
- name: Invalidate CloudFront distribution cache | |
run: >- | |
aws cloudfront create-invalidation | |
--distribution ${{ vars.SITE_CLOUDFRONT_DISTRIBUTION_ID }} | |
--paths "/*" |