ci: registry host and image path configurable via secrets with defaults
This commit is contained in:
1 parent
02cb6b1079
commit
a6f1fea261
2 files changed
+30
-12
No files matched your search
@@ -9,6 +9,13 @@ on:
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
# every value can be overridden by a repository secret; the defaults below
|
||||
# keep the workflow usable without extra configuration
|
||||
env:
|
||||
REGISTRY: ${{ secrets.REGISTRY }}
|
||||
REGISTRY_REPO: ${{ secrets.REGISTRY_REPO }}
|
||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -34,22 +41,27 @@ jobs:
|
||||
oras version
|
||||
|
||||
- name: Push to registry
|
||||
env:
|
||||
REGISTRY: registry.familie-berner.de
|
||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
run: |
|
||||
set -eu
|
||||
REGISTRY="${REGISTRY:-registry.familie-berner.de}"
|
||||
REGISTRY_REPO="${REGISTRY_REPO:-xigmanas/vmmngr}"
|
||||
[ -n "${REGISTRY_USER:-}" ] || { echo "secret REGISTRY_USER is missing" >&2; exit 1; }
|
||||
[ -n "${REGISTRY_TOKEN:-}" ] || { echo "secret REGISTRY_TOKEN is missing" >&2; exit 1; }
|
||||
|
||||
VERSION=$(cat version.txt | tr -d '\n')
|
||||
PKG=$(ls dist/vmmngr-*.tar.gz | head -1)
|
||||
PKG_SUM="${PKG}.sha256"
|
||||
MEDIA="application/vnd.xigmanas.vmmngr.layer.v1.tar+gzip"
|
||||
|
||||
echo "registry : ${REGISTRY}"
|
||||
echo "image : ${REGISTRY}/${REGISTRY_REPO}"
|
||||
echo "version : ${VERSION}"
|
||||
|
||||
echo "$REGISTRY_TOKEN" | oras login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin
|
||||
|
||||
for TAG in "$VERSION" latest; do
|
||||
echo "pushing $REGISTRY/xigmanas/vmmngr:$TAG"
|
||||
oras push "$REGISTRY/xigmanas/vmmngr:$TAG" \
|
||||
echo "pushing ${REGISTRY}/${REGISTRY_REPO}:${TAG}"
|
||||
oras push "${REGISTRY}/${REGISTRY_REPO}:${TAG}" \
|
||||
--artifact-type application/vnd.xigmanas.extension.v1 \
|
||||
"$PKG:$MEDIA" \
|
||||
"$PKG_SUM:application/vnd.xigmanas.sha256" \
|
||||
@@ -59,11 +71,13 @@ jobs:
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
REGISTRY="${REGISTRY:-registry.familie-berner.de}"
|
||||
REGISTRY_REPO="${REGISTRY_REPO:-xigmanas/vmmngr}"
|
||||
VERSION=$(cat version.txt | tr -d '\n')
|
||||
{
|
||||
echo "### vmmngr ${VERSION}"
|
||||
echo ""
|
||||
echo "Package: \`dist/vmmngr-${VERSION}.tar.gz\`"
|
||||
echo ""
|
||||
echo "Pull: \`oras pull registry.familie-berner.de/xigmanas/vmmngr:${VERSION}\`"
|
||||
echo "Pull: \`oras pull ${REGISTRY}/${REGISTRY_REPO}:${VERSION}\`"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -103,12 +103,16 @@ The Gitea workflow `.gitea/workflows/release.yaml` runs on tags `v*` or manually
|
||||
3. pushes it as OCI artifact to `registry.familie-berner.de/xigmanas/vmmngr:<version>`
|
||||
and `:latest` using `oras`
|
||||
|
||||
Required repository secrets:
|
||||
Repository secrets (all optional except the credentials):
|
||||
|
||||
| Secret | Purpose |
|
||||
|---|---|
|
||||
| `REGISTRY_USER` | registry account (needs write access to `xigmanas/vmmngr`) |
|
||||
| `REGISTRY_TOKEN` | password / access token for that account |
|
||||
| Secret | Default | Purpose |
|
||||
|---|---|---|
|
||||
| `REGISTRY` | `registry.familie-berner.de` | registry host |
|
||||
| `REGISTRY_REPO` | `xigmanas/vmmngr` | image path inside the registry |
|
||||
| `REGISTRY_USER` | — (required) | account with write access to the repository |
|
||||
| `REGISTRY_TOKEN` | — (required) | password / access token for that account |
|
||||
|
||||
Unset values fall back to the defaults, so only the two credentials must exist.
|
||||
|
||||
Tagging a release:
|
||||
|
||||
|
||||
Reference in new issue
Block a user