Skip to content

Build Website

Build Website #1

Workflow file for this run

---
name: Build Website
on:
workflow_dispatch:
inputs:
ref:
description: 'Git ref to build from'
type: string
required: true
default: 'main'
workflow_call:
inputs:
ref:
description: 'Git ref to build from'
type: string
required: true
outputs:
tag:
description: 'Archive tag generated by build'
value: '${{ jobs.setup.outputs.tag }}'
permissions:
contents: read
packages: write
jobs:
setup:
runs-on: ubuntu-24.04
timeout-minutes: 1
outputs:
archive: '${{ steps.set-params.outputs.archive }}'
name: '${{ steps.set-params.outputs.name }}'
repo: '${{ steps.set-params.outputs.repo }}'
tag: '${{ steps.set-params.outputs.tag }}'
steps:
- uses: actions/checkout@v6
with:
ref: '${{ inputs.ref }}'
fetch-depth: 1
- name: Set Project Params
id: set-params
run: |
TAG="$(date +'%Y%m%d')-g$(git log --format=%h --max-count=1 |tr -d '\n')"
# This variable expansion downcases the "org/repo" github repository
# string as Docker registries do not allow uppercase in namespace segments.
REPO="${GITHUB_REPOSITORY,,}"
NAME="$(basename $REPO)"
ARCHIVE="${NAME}_${TAG}.tar.xz"
printf 'archive=%s\n' "$ARCHIVE" | tee -a $GITHUB_OUTPUT
printf 'name=%s\n' "$NAME" | tee -a $GITHUB_OUTPUT
printf 'repo=%s\n' "$REPO" | tee -a $GITHUB_OUTPUT
printf 'tag=%s\n' "$TAG" | tee -a $GITHUB_OUTPUT
build:
runs-on: ubuntu-24.04
timeout-minutes: 1
needs:
- setup
env:
ARCHIVE: '${{ needs.setup.outputs.archive }}'
steps:
- uses: actions/checkout@v6
with:
ref: '${{ inputs.ref }}'
fetch-depth: 1
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Build website
run: |
bundle exec jekyll build
- name: Archive website
run: |
root_dir="${ARCHIVE%%.tar.xz}"
mv _site "$root_dir"
tar -cJf "$ARCHIVE" "$root_dir"
- uses: oras-project/setup-oras@v2
- name: ORAS Login
run: |
printf '%s\n' "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u github
- name: ORAS Push
run:
oras push ghcr.io/${{ needs.setup.outputs.repo }}/${{ needs.setup.outputs.name }}:${{ needs.setup.outputs.tag }} --artifact-type application/x-gtar "$ARCHIVE"