Publish container images with Gitea Actions
Some checks failed
Build and Publish Container / publish (push) Failing after 1m34s
Some checks failed
Build and Publish Container / publish (push) Failing after 1m34s
This commit is contained in:
44
.gitea/workflows/publish-container.yml
Normal file
44
.gitea/workflows/publish-container.yml
Normal 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
|
||||
Reference in New Issue
Block a user