Github Actions Build Hugo Static Site and Archive Build Result to Artifact

16 Januari 2022 • 1 menit untuk membaca artikel ini

cat .github/workflows/main.yml
name: Build Hugo Static Website

on:
  push:
    branches: [ hugo.sumarsono.com ]
  pull_request:
    branches: [ main ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-20.04
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - name: Git checkout and update theme
        uses: actions/[email protected]
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - name: Get commit short SHA
        run: echo "SHORT_SHA=`git rev-parse --short HEAD`" >> $GITHUB_ENV

      - name: Setup hugo
        uses: peaceiris/[email protected]
        with:
          hugo-version: "0.92.2"
          extended: true

      - name: Cache Hugo module
        uses: actions/[email protected]
        with:
          path: /tmp/hugo_cache
          key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
          restore-keys: |
                        ${{ runner.os }}-hugomod-

      - name: Build website
        run: hugo --minify

      - name: Archive build result to artifacts
        uses: actions/[email protected]
        with:
          name: build-result-${{ env.SHORT_SHA }}
          path: |
                        public

Sumarsono

DevOps Engineer
Kembali ke atas

Docker Compose: Traefik Ghost Mysql Docker Compose>>

<<Ubuntu 20.04 Tagged Vlan