bold #7
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 | |
on: | |
push: | |
branches: ["main"] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
id-token: write | |
concurrency: | |
group: "deploy" | |
cancel-in-progress: false | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
HUGO_VERSION: 0.81.0 | |
steps: | |
- name: Install Hugo CLI | |
run: | | |
wget -O ${{ runner.temp }}/hugo.deb https://GitHub.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.deb \ | |
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb | |
- name: Install Dart Sass | |
run: sudo snap install dart-sass | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
# - name: Install Node.js dependencies | |
# run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" | |
- name: Build with Hugo | |
env: | |
HUGO_ENVIRONMENT: production | |
HUGO_ENV: production | |
run: | | |
hugo \ | |
--minify \ | |
- name: Upload a Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: hugo-site | |
path: ./public | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download artifacts (Docker images) from previous workflows | |
uses: actions/download-artifact@v4 | |
with: | |
name: hugo-site | |
path: ./public | |
- name: "Configure AWS Credentials" | |
uses: aws-actions/[email protected] | |
with: | |
aws-region: us-east-1 | |
role-to-assume: arn:aws:iam::867712374939:role/github-actions-ianferguson.io | |
role-session-name: GithubActions-Deployer | |
mask-aws-account-id: true | |
- name: Sync to S3 | |
id: deployment | |
run: aws s3 sync ./public/ s3://ianferguson.io --size-only --delete --cache-control max-age=31536000 | |
- name: Cloudfront Invalidation | |
id: flushcache | |
run: aws cloudfront create-invalidation --distribution-id E33GWS6MGOFKJZ --paths "/*" |