Skip to content

attempt to fix build #23

attempt to fix build

attempt to fix build #23

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@v3
- 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:
- name: Git Checkout
uses: actions/checkout@v3
# with:
# submodules: recursive # Fetch Hugo themes (true OR recursive)
# fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Get submodules
run: git submodule update --init --recursive
- name: Install Hugo
run: sudo apt install hugo -y
- name: Build site artifacts
run: hugo --minify # Builds into folder named "public"
- 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@v3
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