From b51adf34105ebe970cffd08d623afe097d6b25be Mon Sep 17 00:00:00 2001 From: moilanik Date: Sun, 14 Jun 2026 09:55:53 +0300 Subject: [PATCH] adfhadfh --- .gitea/workflows/build_publish-artifact.yml | 33 +++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/build_publish-artifact.yml b/.gitea/workflows/build_publish-artifact.yml index 4cf0a3a..ec7a5e3 100644 --- a/.gitea/workflows/build_publish-artifact.yml +++ b/.gitea/workflows/build_publish-artifact.yml @@ -73,16 +73,26 @@ jobs: - uses: actions/checkout@v4 - name: Build container + shell: bash run: | VERSION="${{ needs.check.outputs.version }}" NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ) + set +e docker build \ --label "git.commit=${GITHUB_SHA:0:8}" \ --label "git.commitBy=${GITHUB_ACTOR}" \ --label "build.date=${NOW}" \ -t "minimal:${VERSION}" . + BUILD_EXIT=$? mkdir -p /tmp/image - docker save "minimal:${VERSION}" -o /tmp/image/artifact.tar + if [ "${BUILD_EXIT}" = "0" ]; then + docker save "minimal:${VERSION}" -o /tmp/image/artifact.tar + bash scripts/report-status.sh success "Docker build OK" ci-build container + else + bash scripts/report-status.sh failure "Docker build FAILED" ci-build container + fi + echo "BUILD_EXIT=${BUILD_EXIT}" >> "${GITHUB_ENV}" + exit ${BUILD_EXIT} - name: Save Docker image for next job uses: actions/upload-artifact@v4 @@ -101,6 +111,8 @@ jobs: env: DOCKER_HOST: tcp://docker:2375 steps: + - uses: actions/checkout@v4 + - name: Load saved Docker image uses: actions/download-artifact@v4 with: @@ -108,23 +120,36 @@ jobs: path: /tmp/image - name: Push to Gitea Packages + shell: bash run: | VERSION="${{ needs.check.outputs.version }}" + set +e docker load -i /tmp/image/artifact.tar REGISTRY=$(echo "$GITEA_API_URL" | sed 's|https://||') IMAGE="$REGISTRY/niko/gitea-ci-library/minimal:$VERSION" docker tag "minimal:$VERSION" "$IMAGE" docker login "$REGISTRY" -u niko -p "$GITEA_TOKEN" docker push "$IMAGE" - docker logout "$REGISTRY" + PUSH_EXIT=$? + docker logout "$REGISTRY" > /dev/null 2>&1 + if [ "${PUSH_EXIT}" = "0" ]; then + bash scripts/report-status.sh success "Docker push OK" ci-push container + else + bash scripts/report-status.sh failure "Docker push FAILED" ci-push container + fi + exit ${PUSH_EXIT} tag-commit: needs: [check, push] runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + - name: Create git tag + shell: bash run: | VERSION="${{ needs.check.outputs.version }}" + set +e HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ "$GITEA_API_URL/api/v1/repos/$GITHUB_REPOSITORY/tags" \ -H "Authorization: token $GITEA_TOKEN" \ @@ -137,9 +162,11 @@ jobs: if [ "$HTTP_CODE" = "201" ]; then echo "Tag $VERSION created" + bash scripts/report-status.sh success "Tag $VERSION" ci-tag container elif [ "$HTTP_CODE" = "409" ]; then echo "Tag $VERSION already exists (parallel build won), skipping" + bash scripts/report-status.sh success "Tag exists" ci-tag container else - echo "Failed to create tag: HTTP $HTTP_CODE" + bash scripts/report-status.sh failure "Tag FAILED HTTP $HTTP_CODE" ci-tag container exit 1 fi