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:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -34,22 +41,27 @@ jobs:
|
|||||||
oras version
|
oras version
|
||||||
|
|
||||||
- name: Push to registry
|
- name: Push to registry
|
||||||
env:
|
|
||||||
REGISTRY: registry.familie-berner.de
|
|
||||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
|
||||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
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')
|
VERSION=$(cat version.txt | tr -d '\n')
|
||||||
PKG=$(ls dist/vmmngr-*.tar.gz | head -1)
|
PKG=$(ls dist/vmmngr-*.tar.gz | head -1)
|
||||||
PKG_SUM="${PKG}.sha256"
|
PKG_SUM="${PKG}.sha256"
|
||||||
MEDIA="application/vnd.xigmanas.vmmngr.layer.v1.tar+gzip"
|
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
|
echo "$REGISTRY_TOKEN" | oras login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin
|
||||||
|
|
||||||
for TAG in "$VERSION" latest; do
|
for TAG in "$VERSION" latest; do
|
||||||
echo "pushing $REGISTRY/xigmanas/vmmngr:$TAG"
|
echo "pushing ${REGISTRY}/${REGISTRY_REPO}:${TAG}"
|
||||||
oras push "$REGISTRY/xigmanas/vmmngr:$TAG" \
|
oras push "${REGISTRY}/${REGISTRY_REPO}:${TAG}" \
|
||||||
--artifact-type application/vnd.xigmanas.extension.v1 \
|
--artifact-type application/vnd.xigmanas.extension.v1 \
|
||||||
"$PKG:$MEDIA" \
|
"$PKG:$MEDIA" \
|
||||||
"$PKG_SUM:application/vnd.xigmanas.sha256" \
|
"$PKG_SUM:application/vnd.xigmanas.sha256" \
|
||||||
@@ -59,11 +71,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Summary
|
- name: Summary
|
||||||
run: |
|
run: |
|
||||||
|
REGISTRY="${REGISTRY:-registry.familie-berner.de}"
|
||||||
|
REGISTRY_REPO="${REGISTRY_REPO:-xigmanas/vmmngr}"
|
||||||
VERSION=$(cat version.txt | tr -d '\n')
|
VERSION=$(cat version.txt | tr -d '\n')
|
||||||
{
|
{
|
||||||
echo "### vmmngr ${VERSION}"
|
echo "### vmmngr ${VERSION}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Package: \`dist/vmmngr-${VERSION}.tar.gz\`"
|
echo "Package: \`dist/vmmngr-${VERSION}.tar.gz\`"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Pull: \`oras pull registry.familie-berner.de/xigmanas/vmmngr:${VERSION}\`"
|
echo "Pull: \`oras pull ${REGISTRY}/${REGISTRY_REPO}:${VERSION}\`"
|
||||||
} >> "$GITHUB_STEP_SUMMARY"
|
} >> "$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>`
|
3. pushes it as OCI artifact to `registry.familie-berner.de/xigmanas/vmmngr:<version>`
|
||||||
and `:latest` using `oras`
|
and `:latest` using `oras`
|
||||||
|
|
||||||
Required repository secrets:
|
Repository secrets (all optional except the credentials):
|
||||||
|
|
||||||
| Secret | Purpose |
|
| Secret | Default | Purpose |
|
||||||
|---|---|
|
|---|---|---|
|
||||||
| `REGISTRY_USER` | registry account (needs write access to `xigmanas/vmmngr`) |
|
| `REGISTRY` | `registry.familie-berner.de` | registry host |
|
||||||
| `REGISTRY_TOKEN` | password / access token for that account |
|
| `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:
|
Tagging a release:
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user