diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b57e60c..df4e193 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,48 +1,80 @@ # -name: Create and publish a Docker image +name: Build and publish wylab SS14 server -# Configures this workflow to run every time a change is pushed to the branch called `release`. +# Build whenever the Docker wrapper changes. on: push: branches: ['main'] + repository_dispatch: + types: ['ss14-package-ready'] + workflow_dispatch: -# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +# Workflow-wide defaults. Adjust IMAGE_NAME/REGISTRY if you are publishing elsewhere. env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + 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 -# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. jobs: build-and-push-image: runs-on: ubuntu-latest - # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. permissions: contents: read packages: write - # steps: - name: Checkout repository uses: actions/checkout@v4 - # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. - - name: Log in to the Container registry + + - 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: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. - # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. - # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + username: ${{ secrets.REGISTRY_USERNAME || github.actor }} + password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }} + + - name: Check for existing image + id: image-check + env: + TARGET_TAG: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.wylab.outputs.commit }} + run: | + if docker manifest inspect "$TARGET_TAG" >/dev/null 2>&1; then + echo "exists=true" >> "$GITHUB_OUTPUT" + echo "Image $TARGET_TAG already exists; skipping build." + else + echo "exists=false" >> "$GITHUB_OUTPUT" + fi + - name: Build and push Docker image + if: ${{ steps.image-check.outputs.exists != 'true' }} uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + 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 }} diff --git a/README.md b/README.md index 488ac53..b6cbf9b 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ This project is for those who prefer containerized solutions. It's based on the --build-arg SOURCE_REPO=https://git.wylab.me/wylab/wylab-station-14.git \ --build-arg SOURCE_REF=master \ --build-arg TARGET_PLATFORM=linux-x64 \ - -t wylab-ss14-server . + -t git.wylab.me/wylab/WS14-Docker-Linux-Server:local . ``` - `SOURCE_REPO` – Git URL of the content repo to compile (defaults to the wylab fork). @@ -54,7 +54,7 @@ docker run -d \ -p 5000:5000/udp \ -v /path/on/host:/ss14 \ --name wylab-ss14 \ - wylab-ss14-server + git.wylab.me/wylab/WS14-Docker-Linux-Server:latest ``` On first start the container copies `/ss14-default` into your mounted volume (if empty) so you can edit configs or upload new builds persistently. @@ -66,8 +66,7 @@ version: '3.9' services: ss14-server: - image: wylab-ss14-server - build: . + image: git.wylab.me/wylab/WS14-Docker-Linux-Server:latest ports: - "1212:1212/tcp" - "1212:1212/udp" @@ -78,4 +77,37 @@ services: restart: unless-stopped ``` +### CI/CD + +Two workflows keep this image up to date: + +1. **`wylab-station-14/.github/workflows/publish.yml`** + - Triggered on pushes to `master`, manual dispatch, or nightly cron. + - Checks `https://cdn.wylab.me/fork/wylab/manifest` first; if the current commit already exists on the CDN it exits early. + - Uses `actions/cache` to persist `~/.nuget/packages` and `RobustToolbox/bin`, so repeated builds reuse restored packages/engine binaries when the inputs haven’t changed. + - Otherwise builds the server/client packages via `Content.Packaging`, uploads them via `Tools/publish_multi_request.py`, and fires a `repository_dispatch` event (`event_type: ss14-package-ready`) to this repo. + + Required secrets in the wylab-station-14 repo: + `PUBLISH_TOKEN`, `DOCKER_TRIGGER_TOKEN`, and (if used) `SECRETS_PRIVATE_KEY`. + To send the dispatch, add `DOCKER_TRIGGER_TOKEN` (a PAT with repo access). + +2. **`WS14-Docker-Linux-Server/.github/workflows/main.yml`** + - Triggered on pushes here, manual dispatch, or the `ss14-package-ready` event. + - Resolves the target wylab commit (uses the payload commit if provided). + - Logs into `git.wylab.me` and runs `docker manifest inspect` before building; if an image tagged with that commit already exists it skips the build. + - Otherwise builds the Docker image with `SOURCE_REF=` and pushes: + - `git.wylab.me/wylab/WS14-Docker-Linux-Server:latest` + - `git.wylab.me/wylab/WS14-Docker-Linux-Server:` + - `git.wylab.me/wylab/WS14-Docker-Linux-Server:` + + Required secrets here: `REGISTRY_USERNAME` / `REGISTRY_PASSWORD` (credentials for `git.wylab.me`). + +After the build finishes, Unraid (or any host) can pull: + +``` +git.wylab.me/wylab/WS14-Docker-Linux-Server:latest +``` + +Use that string in Unraid’s “Repository” field and map `/ss14` to persistent storage. + ---