126 lines
5.2 KiB
YAML
126 lines
5.2 KiB
YAML
name: Build and publish container images
|
|
|
|
on:
|
|
push:
|
|
branches: [main, mk_district]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
images:
|
|
runs-on: ${{ vars.IMAGE_RUNNER_LABEL || 'ubuntu-latest' }}
|
|
# Verified linux/amd64 job tools. The runner label only selects a runner.
|
|
container:
|
|
image: docker.gitea.com/runner-images:ubuntu-latest@sha256:fd911d7417bfbf0f454530e447da95b58001e1df41bbc5e1a8dd35d432575aae
|
|
env:
|
|
REGISTRY: ${{ vars.IMAGE_REGISTRY || 'git.anya.jp' }}
|
|
IMAGE_OWNER: ${{ vars.IMAGE_OWNER || 'anya' }}
|
|
IMAGE_TAG: sha-${{ github.sha }}
|
|
# The pinned image stores Node in its tool cache. Make it available to
|
|
# both shell steps and JavaScript Actions without login-shell setup.
|
|
PATH: /opt/acttoolcache/node/24.19.0/x64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
DOCKER_BUILD_SUMMARY: 'false'
|
|
DOCKER_BUILD_RECORD_UPLOAD: 'false'
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
ref: ${{ github.sha }}
|
|
persist-credentials: false
|
|
|
|
- name: Set up Buildx
|
|
uses: https://github.com/docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
|
with:
|
|
version: v0.34.0
|
|
buildkitd-config-inline: |
|
|
[worker.oci]
|
|
max-parallelism = 2
|
|
|
|
- name: Test release tooling and browser logic
|
|
run: node --test tools/ci/release-images.test.mjs static/js/home-palette-core.test.cjs static/js/csv-core.test.cjs
|
|
|
|
- name: Test
|
|
uses: https://github.com/docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
|
with:
|
|
context: .
|
|
file: Dockerfile
|
|
target: test
|
|
platforms: linux/amd64
|
|
push: false
|
|
|
|
- name: Log in to registry
|
|
uses: https://github.com/docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build PagesWiki
|
|
uses: https://github.com/docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
|
with:
|
|
context: .
|
|
file: Dockerfile
|
|
target: runtime
|
|
platforms: linux/amd64
|
|
load: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/pageswiki-app:${{ env.IMAGE_TAG }}
|
|
labels: |
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
|
|
- name: Build adaptor gateway
|
|
uses: https://github.com/docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
|
with:
|
|
context: .
|
|
file: Dockerfile.adapter-gateway
|
|
platforms: linux/amd64
|
|
load: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/pageswiki-adaptor-gateway:${{ env.IMAGE_TAG }}
|
|
labels: |
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
|
|
- name: Build Excalidraw viewer
|
|
uses: https://github.com/docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
|
with:
|
|
context: .
|
|
file: Dockerfile.excalidraw-viewer
|
|
platforms: linux/amd64
|
|
load: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/pageswiki-excalidraw-viewer:${{ env.IMAGE_TAG }}
|
|
labels: |
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
|
|
- name: Build Gecko relay
|
|
uses: https://github.com/docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
|
with:
|
|
context: .
|
|
file: Dockerfile.gecko-relay
|
|
platforms: linux/amd64
|
|
load: true
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_OWNER }}/pageswiki-gecko-relay:${{ env.IMAGE_TAG }}
|
|
labels: |
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
|
|
# Publish only after all builds succeed. Use the host daemon for registry
|
|
# access; BuildKit does not inherit the runner's /etc/hosts entries.
|
|
- name: Push images
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
for image in pageswiki-app pageswiki-adaptor-gateway pageswiki-excalidraw-viewer pageswiki-gecko-relay; do
|
|
docker push "$REGISTRY/$IMAGE_OWNER/$image:$IMAGE_TAG"
|
|
done
|
|
|
|
- name: Remove local CI image tags
|
|
if: always()
|
|
shell: bash
|
|
run: |
|
|
for image in pageswiki-app pageswiki-adaptor-gateway pageswiki-excalidraw-viewer pageswiki-gecko-relay; do
|
|
ref="$REGISTRY/$IMAGE_OWNER/$image:$IMAGE_TAG"
|
|
if docker image inspect "$ref" >/dev/null 2>&1; then
|
|
docker image rm "$ref" || echo "Could not remove local CI tag: $ref" >&2
|
|
fi
|
|
done
|