Add Gitea Actions registry publish workflow and Unraid auto-update script
Build and Publish Docker Image / test-and-publish (push) Failing after 2m25s
Build and Publish Docker Image / test-and-publish (push) Failing after 2m25s
This commit is contained in:
1 parent
84b08f0cdb
commit
18c492488c
5 files changed
+90
-1
No files matched your search
@@ -0,0 +1,37 @@
|
||||
name: Build and Publish Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test-and-publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
|
||||
- name: Run tracker test suites
|
||||
run: npm test
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.trevorstocks.ca
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Build and push image to git.trevorstocks.ca
|
||||
run: |
|
||||
IMAGE="git.trevorstocks.ca/faroegames/oaktracker"
|
||||
SHA_TAG="sha-$(echo "${{ github.sha }}" | cut -c1-7)"
|
||||
docker build -t "${IMAGE}:latest" -t "${IMAGE}:${SHA_TAG}" .
|
||||
docker push "${IMAGE}:latest"
|
||||
docker push "${IMAGE}:${SHA_TAG}"
|
||||
@@ -64,4 +64,24 @@ docker compose up -d --build
|
||||
- Scheme: `http` (Nginx Proxy Manager handles HTTPS/SSL termination for your subdomain)
|
||||
- Forward Hostname / IP: your Unraid IP (or `professor-oak-tracker` if both containers share a custom Docker bridge network like `proxynet`)
|
||||
- Forward Port: `28473`
|
||||
- Enable Websockets: not required, standard HTTPS/SSL termination works out of the box (for example, `https://oak.trevorstocks.ca/`)
|
||||
|
||||
---
|
||||
|
||||
## Automatic Updates on Unraid (Instead of Manual `git pull`)
|
||||
|
||||
Unraid's Docker dashboard **"apply update"** badge only checks **remote Docker registries**—containers built locally with `docker compose up -d --build` will show updates as `not available`. Choose either approach below:
|
||||
|
||||
### Way 1 — Unraid Dashboard **"apply update"** Button (via Gitea Container Registry)
|
||||
|
||||
1. In Gitea (`git.trevorstocks.ca`), make sure **Packages** and **Actions** (with a Docker runner) are enabled.
|
||||
2. Push to `main`: [`.gitea/workflows/docker-publish.yml`](./.gitea/workflows/docker-publish.yml) runs `npm test` and pushes `git.trevorstocks.ca/faroegames/oaktracker:latest`.
|
||||
3. In Gitea's **Packages** tab for `oaktracker`, set the container package visibility to **Public** (or run `docker login git.trevorstocks.ca` once in the Unraid terminal if keeping it private—note Unraid's automatic UI update checker works most reliably with public HTTPS packages; private custom registries may require clicking **Force Update** or using Watchtower).
|
||||
4. On Unraid, add the container in **Docker → Add Container** (rather than Compose) with:
|
||||
- **Name:** `professor-oak-tracker`
|
||||
- **Repository:** `git.trevorstocks.ca/faroegames/oaktracker:latest`
|
||||
- **Port:** Container `28473` → Host `28473`
|
||||
- Now Unraid detects new pushes in its Docker tab (or Watchtower can auto-update it).
|
||||
|
||||
### Way 2 — Hands-Free Auto-Rebuild via Unraid **User Scripts** (Zero Gitea Runner Needed)
|
||||
|
||||
If you don't run a Gitea Actions Runner, keep building locally with `docker compose` and add [`scripts/unraid-git-update.sh`](./scripts/unraid-git-update.sh) to Unraid's **User Scripts** plugin on a schedule (e.g., `*/15 * * * *`). It checks `git fetch origin main` and only rebuilds/restarts when a new commit is pushed to `git.trevorstocks.ca`.
|
||||
@@ -1,5 +1,8 @@
|
||||
services:
|
||||
professor-oak-tracker:
|
||||
# For local builds on Unraid, use `build:` below.
|
||||
# If publishing via Gitea Actions (.gitea/workflows/docker-publish.yml), you can replace `build:` with:
|
||||
# image: git.trevorstocks.ca/faroegames/oaktracker:latest
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Schedule this in Unraid's "User Scripts" plugin (e.g. every 15 minutes)
|
||||
# to automatically pull & rebuild whenever you push updates to Gitea.
|
||||
|
||||
APP_DIR="/mnt/user/appdata/professor-oak-tracker"
|
||||
BRANCH="main"
|
||||
|
||||
cd "${APP_DIR}"
|
||||
git fetch origin "${BRANCH}" --quiet
|
||||
|
||||
LOCAL_SHA="$(git rev-parse HEAD)"
|
||||
REMOTE_SHA="$(git rev-parse "origin/${BRANCH}")"
|
||||
|
||||
if [ "${LOCAL_SHA}" != "${REMOTE_SHA}" ]; then
|
||||
echo "[oaktracker] Update detected (${LOCAL_SHA:0:7} -> ${REMOTE_SHA:0:7}), rebuilding container..."
|
||||
git pull --ff-only origin "${BRANCH}"
|
||||
docker compose up -d --build
|
||||
docker image prune -f >/dev/null 2>&1 || true
|
||||
echo "[oaktracker] Updated cleanly to ${REMOTE_SHA:0:7}."
|
||||
fi
|
||||
@@ -169,4 +169,11 @@ test('Both trackers expose a relative Hub navigation link and valid Docker/Nginx
|
||||
assert.ok(nginxConf.includes('application/javascript mjs;'));
|
||||
assert.ok(nginxConf.includes('location = /oras'));
|
||||
assert.ok(nginxConf.includes('location = /luminescent-platinum'));
|
||||
|
||||
const giteaWorkflow = await fs.readFile(path.join(ROOT_DIR, '.gitea/workflows/docker-publish.yml'), 'utf8');
|
||||
assert.ok(giteaWorkflow.includes('git.trevorstocks.ca/faroegames/oaktracker'));
|
||||
assert.ok(giteaWorkflow.includes('secrets.GITEA_TOKEN'));
|
||||
|
||||
const updateScript = await fs.readFile(path.join(ROOT_DIR, 'scripts/unraid-git-update.sh'), 'utf8');
|
||||
assert.ok(updateScript.includes('docker compose up -d --build'));
|
||||
});
|
||||
Reference in new issue
Block a user