Skip to content

add publish workflow #6

add publish workflow

add publish workflow #6

Workflow file for this run

name: Publish
permissions:
id-token: write
contents: read
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Read .env
id: hugo-version
run: |
. ./.env.hugo
echo "HUGO_VERSION=${HUGO_VERSION}" >> "${GITHUB_OUTPUT}"
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: "${{ steps.hugo-version.outputs.HUGO_VERSION }}"
extended: true
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::440407409673:role/Github_Actions_Personal_Website
role-session-name: s3session
aws-region: eu-central-1
- name: Sync assets with S3
shell: bash
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
run:
aws s3 sync ./public s3://$AWS_S3_BUCKET --size-only --delete
--exclude '*.webp'
- name: Sync WebP images with S3 bucket
shell: bash
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
run:
aws s3 sync ./public s3://$AWS_S3_BUCKET --size-only --delete
--no-guess-mime-type --content-type image/webp --exclude '*'
--include '*.webp'