Publish container images with Gitea Actions
Some checks failed
Build and Publish Container / publish (push) Failing after 1m34s

This commit is contained in:
hhqyb
2026-07-26 15:13:52 +08:00
parent 7a1f20bd3f
commit 3c5679f31e
2 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
name: Build and Publish Container
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
env:
REGISTRY: gitea.dddbg.com
IMAGE: gitea.dddbg.com/youbin/stun-nat
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Log in to Gitea Container Registry
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
test -n "$REGISTRY_TOKEN" || { echo "Missing Actions secret: REGISTRY_TOKEN"; exit 1; }
printf '%s' "$REGISTRY_TOKEN" | docker login "$REGISTRY" --username youbin --password-stdin
- name: Build and push image
run: |
SHA_TAG="sha-${GITEA_SHA}"
docker build --pull --tag "${IMAGE}:${SHA_TAG}" .
docker push "${IMAGE}:${SHA_TAG}"
if [ "$GITEA_REF" = "refs/heads/main" ]; then
docker tag "${IMAGE}:${SHA_TAG}" "${IMAGE}:latest"
docker push "${IMAGE}:latest"
fi
case "$GITEA_REF" in
refs/tags/v*)
docker tag "${IMAGE}:${SHA_TAG}" "${IMAGE}:${GITEA_REF_NAME}"
docker push "${IMAGE}:${GITEA_REF_NAME}"
;;
esac