Files
timerr/.gitea/workflows/docker-image.yml
T
MS.Kondratev d66d52bc65
Build and publish Docker image / publish (push) Failing after 2m12s
ci: publish Docker image and create release
2026-07-15 14:52:16 +05:00

73 lines
2.1 KiB
YAML

name: Build and publish Docker image
on:
push:
branches:
- main
permissions:
contents: read
packages: write
releases: write
env:
REGISTRY: git.spyk3r.com
IMAGE_NAME: spyk3r/timerr
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Build and publish image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }}
- name: Create Gitea release
shell: bash
env:
API_URL: ${{ gitea.api_url }}
REPOSITORY: ${{ gitea.repository }}
COMMIT_SHA: ${{ gitea.sha }}
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
set -euo pipefail
tag="build-${COMMIT_SHA}"
release_url="${API_URL}/repos/${REPOSITORY}/releases"
status=$(curl --silent --output /dev/null --write-out '%{http_code}' \
--header "Authorization: token ${GITEA_TOKEN}" \
"${release_url}/tags/${tag}")
if [ "${status}" = "200" ]; then
echo "Release ${tag} already exists"
exit 0
fi
if [ "${status}" != "404" ]; then
echo "Unable to check release ${tag}: HTTP ${status}" >&2
exit 1
fi
curl --fail-with-body --request POST \
--header "Authorization: token ${GITEA_TOKEN}" \
--header "Content-Type: application/json" \
--data "{\"tag_name\":\"${tag}\",\"target_commitish\":\"${COMMIT_SHA}\",\"name\":\"Build ${COMMIT_SHA}\",\"body\":\"Docker image: ${REGISTRY}/${IMAGE_NAME}:${COMMIT_SHA}\",\"draft\":false,\"prerelease\":false}" \
"${release_url}"