www.byjp.me/.github/workflows/publish.yml
2025-01-31 11:33:43 +00:00

142 lines
4.2 KiB
YAML

name: Deploy Hugo site to Pages
on:
push:
branches: ["main"]
paths-ignore:
- indiekit/**
- .github/workflows/indiekit-docker.yml
- tools/**
schedule:
# Rebuild every day, to update 'year relative' dates, change now page & calendar
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.140.2
PAGEFIND_VERSION: 1.3.0
TASK_VERSION: 3.40.1
steps:
- name: Install Hugo CLI
run: |
wget -q -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Pagefind CLI
run: |
wget -q -O ${{ runner.temp }}/pagefind.tar.gz https://github.com/CloudCannon/pagefind/releases/download/v${PAGEFIND_VERSION}/pagefind-v${PAGEFIND_VERSION}-x86_64-unknown-linux-musl.tar.gz \
&& tar -xpf ${{ runner.temp }}/pagefind.tar.gz pagefind \
&& mv pagefind /usr/local/bin/pagefind
- name: Install Task CLI
run: |
wget -q -O ${{ runner.temp }}/task.tar.gz https://github.com/go-task/task/releases/download/v${TASK_VERSION}/task_linux_amd64.tar.gz \
&& tar -xpf ${{ runner.temp }}/task.tar.gz task \
&& mv task /usr/local/bin/task
- name: Checkout
uses: actions/checkout@v3
with:
path: ./www.byjp.me
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v2
- name: Cache Hugo persistent info
uses: actions/cache@v3
env:
cache-name: hugo-persistent-cache
with:
path: /tmp/hugo
key: ${{ env.cache-name }}
- name: Build site
working-directory: ./www.byjp.me
run: |
task build
mv ./public/index.redirects ../new_redirects
- name: Upload site artifact
uses: actions/upload-pages-artifact@v3
with:
name: site
path: ./www.byjp.me/public
- name: Checkout byjp.fyi
uses: actions/checkout@v4
with:
repository: by-jp/byjp.fyi
path: ./byjp.fyi
token: ${{ secrets.SHORTLINK_REPO_PAT }}
- name: Update blog shortlinks
working-directory: ./byjp.fyi
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
cat ../new_redirects | ../www.byjp.me/tools/redirects/update-shortlinks.bash
- name: Build Gemini capsule
working-directory: ./www.byjp.me
run: task gemini-reduce
- name: Upload capsule artifact
uses: actions/upload-artifact@v4
with:
name: capsule
path: ./www.byjp.me/public
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
with:
artifact_name: site
ipfs-publish:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v3
with:
name: site
path: ./public
- name: Extract Github Pages artifact
working-directory: ./public
run: tar -xf ./artifact.tar
- name: Publish to IPFS
id: Publish
uses: aquiladev/ipfs-action@master
with:
path: ./public
service: filebase
pinName: ${{ github.event.repository.name }}
filebaseBucket: microsites
filebaseKey: ${{ secrets.FILEBASE_KEY }}
filebaseSecret: ${{ secrets.FILEBASE_SECRET }}
- name: Update DNS record
uses: XueMoMo/actions-coudflare-dns@v1.0.1
with:
name: ${{ github.event.repository.name }}
cid: ${{ steps.Publish.outputs.cid }}
token: ${{ secrets.CLOUDFLARE_TOKEN }}
zone: ${{ secrets.CLOUDFLARE_ZONE_ID }}