55 lines
1.9 KiB
YAML
55 lines
1.9 KiB
YAML
# Build the site image and push it to this Gitea instance's container
|
|
# registry. Registry host and owner come from the instance itself, so the
|
|
# same file works on the home Gitea and the VPS Gitea without edits.
|
|
#
|
|
# Needs one repo secret: REGISTRY_TOKEN, a personal access token for the
|
|
# repo owner with package read/write scope.
|
|
|
|
name: Build image
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: debian
|
|
env:
|
|
SERVER_URL: ${{ gitea.server_url }}
|
|
OWNER: ${{ gitea.repository_owner }}
|
|
REPO: ${{ gitea.repository }}
|
|
SHA: ${{ gitea.sha }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
# node:24-trixie (Debian 13) has git and node but no Docker CLI. Install
|
|
# the CLI and buildx from Docker's apt repo; the daemon is the runner's.
|
|
- name: Install Docker CLI
|
|
run: |
|
|
install -m 0755 -d /etc/apt/keyrings
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
|
|
chmod a+r /etc/apt/keyrings/docker.asc
|
|
cat > /etc/apt/sources.list.d/docker.sources <<SRC
|
|
Types: deb
|
|
URIs: https://download.docker.com/linux/debian
|
|
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
|
|
Components: stable
|
|
Signed-By: /etc/apt/keyrings/docker.asc
|
|
SRC
|
|
apt-get update
|
|
apt-get install -y --no-install-recommends docker-ce-cli docker-buildx-plugin
|
|
|
|
- name: Log in to registry
|
|
run: |
|
|
REGISTRY="${SERVER_URL#https://}"
|
|
echo "REGISTRY=$REGISTRY" >> "$GITHUB_ENV"
|
|
echo "IMAGE=$REGISTRY/${REPO,,}" >> "$GITHUB_ENV"
|
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$REGISTRY" -u "$OWNER" --password-stdin
|
|
|
|
- name: Build
|
|
run: docker build -t "$IMAGE:latest" -t "$IMAGE:${SHA::12}" .
|
|
|
|
- name: Push
|
|
run: docker push --all-tags "$IMAGE"
|