Files
git-pages/.forgejo/workflows/ci.yaml
T

117 lines
4.7 KiB
YAML

name: CI
on:
push:
pull_request:
workflow_dispatch:
env:
FORGE: codeberg.org
jobs:
check:
runs-on: debian-trixie
container:
image: docker.io/library/node:24-trixie-slim@sha256:ae91dcc111a68c9d2d81ff2a17bda61be126426176fde6fe7d08ab13b7f50573
steps:
- name: Check out source code
uses: https://code.forgejo.org/actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up toolchain
uses: https://code.forgejo.org/actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: '>=1.25.6'
- name: Install dependencies
run: |
apt-get -y update
apt-get -y install ca-certificates
go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Build service
run: |
go build
- name: Run tests
run: |
go test ./...
- name: Run static analysis
run: |
go vet ./...
staticcheck ./...
release:
# IMPORTANT: This workflow step will not work without the Releases unit enabled!
if: ${{ forge.ref == 'refs/heads/main' || startsWith(forge.event.ref, 'refs/tags/v') }}
needs: [check]
runs-on: debian-trixie
container:
image: docker.io/library/node:24-trixie-slim@sha256:ae91dcc111a68c9d2d81ff2a17bda61be126426176fde6fe7d08ab13b7f50573
steps:
- name: Install dependencies
run: |
apt-get -y update
apt-get -y install ca-certificates git
# git needs to be installed for build information embedding to work
- name: Check out source code
uses: https://code.forgejo.org/actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
fetch-tags: true
- name: Set up toolchain
uses: https://code.forgejo.org/actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: '>=1.25.6'
- name: Build release assets
# If you want more platforms to be represented, send a pull request.
run: |
set -x
build() { GOOS=$1 GOARCH=$2 go build -o assets/git-pages.$1-$2$3; }
build windows amd64 .exe
build linux amd64
build linux arm64
build darwin arm64
git archive -o assets/git-pages-src.zip --prefix git-pages/ HEAD
- name: Create release
uses: https://code.forgejo.org/actions/forgejo-release@98265452477dafb3f0f27ba9c462c90b18cb44fd # v2.13.4
with:
tag: ${{ startsWith(forge.event.ref, 'refs/tags/v') && forge.ref_name || 'latest' }}
release-dir: assets
hide-archive-link: true
direction: upload
override: true
prerelease: ${{ !startsWith(forge.event.ref, 'refs/tags/v') }}
package:
if: ${{ forge.ref == 'refs/heads/main' || startsWith(forge.event.ref, 'refs/tags/v') }}
needs: [check]
runs-on: debian-trixie
container:
image: docker.io/library/node:24-trixie-slim@sha256:ae91dcc111a68c9d2d81ff2a17bda61be126426176fde6fe7d08ab13b7f50573
steps:
- name: Install dependencies
run: |
apt-get -y update
apt-get -y install ca-certificates buildah qemu-user-binfmt
- name: Check out source code
uses: https://code.forgejo.org/actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Authenticate with Docker
run: |
buildah login --authfile=/tmp/authfile-${FORGE}.json \
-u ${{ vars.PACKAGES_USER }} -p ${{ secrets.PACKAGES_TOKEN }} ${FORGE}
- name: Build container
run: |
printf '[storage]\ndriver="vfs"\nrunroot="/run/containers/storage"\ngraphroot="/var/lib/containers/storage"\n' | tee /etc/containers/storage.conf
buildah build ${CACHE} --arch=amd64 --tag=container:${VER}-amd64
buildah build ${CACHE} --arch=arm64 --tag=container:${VER}-arm64
buildah manifest create container:${VER} \
container:${VER}-amd64 \
container:${VER}-arm64
env:
BUILDAH_ISOLATION: chroot
VER: ${{ startsWith(forge.event.ref, 'refs/tags/v') && forge.ref_name || 'latest' }}
CACHE: ${{ format('--authfile=/tmp/authfile-{0}.json --layers --cache-from {0}/{1}/cache --cache-to {0}/{1}/cache', env.FORGE, forge.repository) }}
- if: ${{ forge.repository == 'git-pages/git-pages' }}
name: Push container to Codeberg
run: |
buildah manifest push --authfile=/tmp/authfile-${FORGE}.json \
--all container:${VER} "docker://${FORGE}/${{ forge.repository }}:${VER/v/}"
env:
VER: ${{ startsWith(forge.event.ref, 'refs/tags/v') && forge.ref_name || 'latest' }}