Files
WS14-Docker-Linux-Server/.github/workflows/main.yml
2025-12-14 09:31:15 +01:00

77 lines
2.4 KiB
YAML

#
name: Build and publish wylab SS14 server
# Build whenever the Docker wrapper changes.
on:
push:
branches: ['main']
repository_dispatch:
types: ['ss14-package-ready']
workflow_dispatch:
# Workflow-wide defaults. Adjust IMAGE_NAME/REGISTRY if you are publishing elsewhere.
env:
REGISTRY: git.wylab.me
IMAGE_NAME: wylab/ws14-docker-linux-server
TARGET_PLATFORM: linux-x64
WYLAB_SOURCE_REPO: https://git.wylab.me/wylab/wylab-station-14.git
WYLAB_SOURCE_REF: master
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Add git.wylab.me host mapping
run: |
if ! grep -q "$HOST_NAME" /etc/hosts; then
echo "$HOST_IP $HOST_NAME" | sudo tee -a /etc/hosts
fi
env:
HOST_IP: 172.17.0.3
HOST_NAME: git.wylab.me
- name: Checkout repository
uses: actions/checkout@v4
- name: Resolve wylab commit
id: wylab
env:
PAYLOAD_COMMIT: ${{ github.event.client_payload.commit }}
run: |
set -euo pipefail
if [ -n "${PAYLOAD_COMMIT}" ]; then
COMMIT="${PAYLOAD_COMMIT}"
else
REF="${WYLAB_SOURCE_REF}"
COMMIT=$(git ls-remote "${WYLAB_SOURCE_REPO}" "${REF}" | head -n1 | cut -f1)
fi
if [ -z "${COMMIT}" ]; then
echo "Unable to resolve commit to build." >&2
exit 1
fi
echo "commit=${COMMIT}" >> "$GITHUB_OUTPUT"
- name: Log in to the container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME || github.actor }}
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.wylab.outputs.commit }}
build-args: |
SOURCE_REPO=${{ env.WYLAB_SOURCE_REPO }}
SOURCE_REF=${{ steps.wylab.outputs.commit }}
TARGET_PLATFORM=${{ env.TARGET_PLATFORM }}