ci: set the image registry explicitly
- use REGISTRY (git.hq.ars9.space) for login and image tags instead of deriving it from the server url, which is the runner's registration address and may be internal-only - document how jobs reach gitea when the runner uses an internal address
This commit is contained in:
1 parent
f24a1b7dd5
commit
cafc126d1b
2 files changed
+11
-6
No files matched your search
@@ -4,7 +4,9 @@
|
||||
# version and `latest`.
|
||||
#
|
||||
# Needs a repository (or owner) secret REGISTRY_TOKEN: a Gitea access token
|
||||
# with package write access for the repository owner.
|
||||
# with package write access for the repository owner. The registry host is
|
||||
# set explicitly below rather than taken from the server URL, which is the
|
||||
# address the runner was registered with and may be internal-only.
|
||||
|
||||
name: CI
|
||||
|
||||
@@ -13,6 +15,9 @@ on:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
REGISTRY: git.hq.ars9.space
|
||||
|
||||
jobs:
|
||||
server:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -91,10 +96,8 @@ jobs:
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
OWNER: ${{ github.repository_owner }}
|
||||
run: |
|
||||
registry="${GITHUB_SERVER_URL#*://}"
|
||||
echo "REGISTRY=${registry}" >> "$GITHUB_ENV"
|
||||
echo "IMAGE=${registry}/$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
|
||||
echo "$REGISTRY_TOKEN" | docker login "$registry" -u "$OWNER" --password-stdin
|
||||
echo "IMAGE=${REGISTRY}/$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
|
||||
echo "$REGISTRY_TOKEN" | docker login "$REGISTRY" -u "$OWNER" --password-stdin
|
||||
- name: Build
|
||||
run: docker build -t "${IMAGE}:${VERSION}" -t "${IMAGE}:latest" .
|
||||
- name: Push
|
||||
|
||||
+3
-1
@@ -224,10 +224,12 @@ docker compose build --no-cache
|
||||
|
||||
- **server**: lint (no warnings allowed), type-check, tests, build.
|
||||
- **client**: lint (no warnings allowed), build, Storybook tests in headless Chromium.
|
||||
- **image** (pushes to `master` only): when the push changes `version` in the root `package.json`, and both check jobs pass, builds the Docker image and pushes it to the Gitea instance's container registry as `<gitea host>/<owner>/<repo>:<version>` and `:latest`.
|
||||
- **image** (pushes to `master` only): when the push changes `version` in the root `package.json`, and both check jobs pass, builds the Docker image and pushes it to the Gitea container registry set by `REGISTRY` at the top of the workflow (`git.hq.ars9.space`) as `<registry>/<owner>/<repo>:<version>` and `:latest`.
|
||||
|
||||
The image job logs in as the repository owner with the `REGISTRY_TOKEN` secret: a Gitea access token with package write access (Settings → Applications → token with `write:package`), added under the repository's Settings → Actions → Secrets. It runs `docker` on the runner, so the runner must give jobs access to a Docker daemon (act_runner mounts the host's Docker socket into job containers by default).
|
||||
|
||||
Jobs clone the repository from the address the runner was registered with. If that's an internal hostname (such as `http://gitea:3000` from Gitea's compose network), job containers can't resolve it: either register the runner with the public URL, or set `container.network` in the act_runner config to Gitea's Docker network so jobs join it.
|
||||
|
||||
---
|
||||
|
||||
## Running with Docker Compose
|
||||
|
||||
Reference in new issue
Block a user