upgrade hugo to 0.124.0 #25
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: Build and deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
get-short-sha: | |
name: Get short SHA | |
runs-on: ubuntu-22.04 | |
outputs: | |
short-sha: ${{ steps.short-sha.outputs.short-sha }} | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
- name: Get short SHA | |
id: short-sha | |
run: | | |
echo "short-sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | |
build-and-deploy: | |
name: Build and deploy | |
needs: get-short-sha | |
runs-on: ubuntu-22.04 | |
env: | |
AWS_REGION: us-east-1 | |
BUILD_VERSION: ${{ github.ref_name }}-${{ needs.get-short-sha.outputs.short-sha }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: "0.124.0" | |
- name: Build | |
run: hugo --minify | |
- name: Add build specifier to site artifacts | |
run: echo "${{ env.BUILD_VERSION }}" >> public/build.txt | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Upload site artifacts to S3 | |
run: aws s3 sync . s3://${{ secrets.S3_BUCKET_NAME }}/ --delete | |
working-directory: public | |
- name: Invalidate CloudFront distribution cache | |
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" | |
post-to-mastodon: | |
name: Post to Mastodon | |
needs: build-and-deploy | |
runs-on: ubuntu-22.04 | |
if: ${{ contains(github.event.head_commit.modified, 'content/posts/') }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # fetch all history for all tags and branches | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.21" | |
- run: go mod download | |
- name: Auto-toot | |
env: | |
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }} | |
MASTODON_ORIGIN: ${{ secrets.MASTODON_ORIGIN }} | |
BLOG_ORIGIN: ${{ secrets.BLOG_ORIGIN }} | |
working-directory: ./auto-toot | |
run: go run main.go |