mrfdn.com - Begini cara saya setup blog ini untuk bisa berjalan di Github action lalu dihost di Deno secara gratis.
Setup workflow file pada source code
File ini hanya akan dikonsumsi oleh github.
Pada root folder hugo, buatlah sebuah folder
.github/workflows/lalu di dalamnya buatlah filemain.yml.Isi file
main.ymluntuk menjelaskan step step apa saja yang akan dilakukan oleh github action nanti. File YML ini sangat sensitif dengan indentasi maupun spasi.
Jadi perhatikan baik-baik yah.
name: Deploy to Deno Deploy
on:
# triggers the workflow on push or pull request events but only for the main branch
push:
branches: main
pull_request:
branches: main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more
# jobs that can run sequentially or in parallel
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
permissions:
id-token: write # Allows authentication with Deno Deploy.
contents: read # Allows cloning the repo.
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: true # Fetch Hugo themes (true or recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
# - name: Setup Node
# uses: actions/setup-node@v4
# with:
# node-version: '20.x'
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: 'latest'
extended: true
- name: Build site
run: hugo --minify
# - name: Run pagefind
# run: npx -y pagefind --site "public"
- name: Deploy to Deno Deploy
uses: denoland/deployctl@v1
with:
project: main # the name of the project on Deno Deploy
entrypoint: https://deno.land/std@0.140.0/http/file_server.ts
root: public # Where the built HTML/CSS/JS files are located.
Kode di atas khusus untuk build Hugo. Silahkan cari workflow lain jika ingin setup stack lain.
Jika gagal build baca saja errornya atau coba ganti hugo version dari latest menjadi versi hugo yang sedang berjalan normal di local anda, sebelumnya misal: 0.152.2.
Setelah itu push ke repo github anda.
Perhatikan pada repo Github anda, lihat tab Actions. Di sana file workflow ini akan berjalan sesuai instruksi yang diberikan di atas.
Semoga bermanfaat. :)