sdgsf
This commit is contained in:
@@ -34,46 +34,20 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: DEBUG - Print Initial Context and Env
|
||||
run: |
|
||||
echo "=== DEBUG: INITIAL CONTEXT ==="
|
||||
echo "gitea.server_url: ${{ gitea.server_url }}"
|
||||
echo "gitea.repository: ${{ gitea.repository }}"
|
||||
echo "github.sha: ${{ github.sha }}"
|
||||
echo "github.actor: ${{ github.actor }}"
|
||||
echo "env.GITEA_API_URL: $GITEA_API_URL"
|
||||
echo "env.REPO: $REPO"
|
||||
if [ -z "$GITEA_TOKEN" ]; then echo "GITEA_TOKEN IS EMPTY!"; else echo "GITEA_TOKEN IS SET"; fi
|
||||
|
||||
- name: Set Gitea status to PENDING
|
||||
run: |
|
||||
echo "===== gitea-ci-library - Check existing artifact | begin ====="
|
||||
bash scripts/report-status.sh pending "Checking version..." ci-check
|
||||
|
||||
- name: Check existing artifact and calculate version
|
||||
id: run_check
|
||||
run: |
|
||||
echo "=== DEBUG: STARTING API CALL ==="
|
||||
RAW_VERSION=$(jq -r '.version' package.json)
|
||||
BASE_VERSION=$(echo "$RAW_VERSION" | cut -d'.' -f1-2)
|
||||
echo "Package.json version: $RAW_VERSION -> Base: $BASE_VERSION"
|
||||
echo "gitea-ci-library - Tunnistettu Major.Minor versio: $BASE_VERSION"
|
||||
|
||||
# Tehdään API-kutsu ilman -f lippua, jotta saadaan HTTP-koodi talteen debuggausta varten
|
||||
HTTP_RESPONSE=$(curl -s -w "%{http_code}" -H "Authorization: token $GITEA_TOKEN" \
|
||||
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/tags" -o /tmp/tags.json)
|
||||
TAGS_JSON=$(curl -s -f -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/tags")
|
||||
|
||||
echo "Gitea API HTTP Status Code: $HTTP_RESPONSE"
|
||||
echo "=== DEBUG: API RESPONSE BODY ==="
|
||||
cat /tmp/tags.json
|
||||
echo "================================="
|
||||
|
||||
# Jos API-kutsu epäonnistui (esim. 401 tai 404), räjäytetään tämä step heti
|
||||
if [ "$HTTP_RESPONSE" -lt 200 ] || [ "$HTTP_RESPONSE" -gt 299 ]; then
|
||||
echo "gitea-ci-library - ERROR: Gitea API returned status $HTTP_RESPONSE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TAGS_JSON=$(cat /tmp/tags.json)
|
||||
TAG=$(echo "$TAGS_JSON" | jq -r 'if type == "array" then .[] | select(.commit.sha == "${{ github.sha }}") | .name else empty end' | head -1)
|
||||
|
||||
mkdir -p /tmp/build-ctx
|
||||
@@ -95,10 +69,6 @@ jobs:
|
||||
echo "gitea-ci-library - Uusi vapaa versio: $FULL_VERSION"
|
||||
fi
|
||||
|
||||
echo "=== DEBUG: CREATED BUILD.ENV ==="
|
||||
cat /tmp/build-ctx/build.env
|
||||
|
||||
# VAIHDETAAN v4 -> v3, JOTTA RIKKOUTUNUT VÄLIMUISTI KIERRETÄÄN
|
||||
- name: Upload build env artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
@@ -117,11 +87,8 @@ jobs:
|
||||
|
||||
- name: Set Gitea status to FAILURE
|
||||
if: failure()
|
||||
run: |
|
||||
echo "===== gitea-ci-library - Check existing artifact | fail ====="
|
||||
bash scripts/report-status.sh failure "Check version FAILED" ci-check
|
||||
run: bash scripts/report-status.sh failure "Check version FAILED" ci-check
|
||||
|
||||
# TIUKKA RIIPPUVUUS: quality-gate käynnistyy vain, jos check ON onnistunut (success)
|
||||
quality-gate:
|
||||
needs: [check]
|
||||
uses: niko/gitea-ci-library/.gitea/workflows/quality-gate.yml@main
|
||||
@@ -134,22 +101,46 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [check, quality-gate]
|
||||
# PAKOTETAAN KÄYNTIIN: always() ohittaa Gitean dynaamisen skippausbugin
|
||||
if: always()
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: DIAGNOSTICS - Inspect Gitea State and Variables
|
||||
run: |
|
||||
echo "=================================================="
|
||||
echo " GITEA ACTIONS STATE INSPECTION "
|
||||
echo "=================================================="
|
||||
echo "needs.check.result: ${{ needs.check.result }}"
|
||||
echo "needs.quality-gate.result: ${{ needs.quality-gate.result }}"
|
||||
echo "job.status: ${{ job.status }}"
|
||||
echo "=================================================="
|
||||
|
||||
- name: Download build env
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: build-context
|
||||
path: /tmp/build-ctx
|
||||
|
||||
- name: Gatekeeper check & DEBUG
|
||||
# TÄMÄ STEPPI VARMISTAA LAADUN JA RÄJÄYTTÄÄ PUTKEN JOS LAATUTESTIT EIVÄT OLLEET SUCCESS
|
||||
- name: Verify Quality Gate and Context
|
||||
id: gatekeeper
|
||||
run: |
|
||||
echo "=== DEBUG: BUILD JOB LITERALLY READS TIEDOSTO ==="
|
||||
cat /tmp/build-ctx/build.env
|
||||
QG_RESULT="${{ needs.quality-gate.result }}"
|
||||
source /tmp/build-ctx/build.env
|
||||
if [ "${ARTIFACT_EXISTS}" = "true" ]; then
|
||||
|
||||
echo "gitea-ci-library - Quality gate tilaksi luettu: $QG_RESULT"
|
||||
echo "gitea-ci-library - Levyltä luettu ARTIFACT_EXISTS: $ARTIFACT_EXISTS"
|
||||
|
||||
# 1. RÄJÄYTETÄÄN PUTKI jos testit feilasivat tai ne peruttiin
|
||||
if [ "$QG_RESULT" != "success" ]; then
|
||||
echo "gitea-ci-library - ERROR: Quality gate pitää läpäistä! Tila oli: $QG_RESULT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2. Päätetään skipataanko build koska kontti on jo tehty
|
||||
if [ "$ARTIFACT_EXISTS" = "true" ]; then
|
||||
echo "gitea-ci-library - Kontti valmiina. Ohitetaan build-vaiheet."
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||
@@ -157,7 +148,9 @@ jobs:
|
||||
|
||||
- name: Set Gitea status to PENDING
|
||||
if: steps.gatekeeper.outputs.skip == 'false'
|
||||
run: bash scripts/report-status.sh pending "Building Docker image..." ci-docker-build
|
||||
run: |
|
||||
echo "===== gitea-ci-library - Docker Build | begin ====="
|
||||
bash scripts/report-status.sh pending "Building Docker image..." ci-docker-build
|
||||
|
||||
- name: Build container
|
||||
if: steps.gatekeeper.outputs.skip == 'false'
|
||||
@@ -191,7 +184,7 @@ jobs:
|
||||
|
||||
- name: Upload Docker image artifact
|
||||
if: steps.gatekeeper.outputs.skip == 'false' && success()
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: docker-image
|
||||
path: /tmp/image/artifact.tar
|
||||
@@ -199,6 +192,7 @@ jobs:
|
||||
push:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [check, build]
|
||||
if: always()
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -208,10 +202,15 @@ jobs:
|
||||
name: build-context
|
||||
path: /tmp/build-ctx
|
||||
|
||||
- name: Gatekeeper check
|
||||
- name: Verify Build Status
|
||||
id: gatekeeper
|
||||
run: |
|
||||
BUILD_RESULT="${{ needs.build.result }}"
|
||||
source /tmp/build-ctx/build.env
|
||||
if [ "$BUILD_RESULT" != "success" ]; then
|
||||
echo "gitea-ci-library - Edellinen vaihe epäonnistui. Keskeytetään." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "${ARTIFACT_EXISTS}" = "true" ]; then
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
@@ -220,14 +219,16 @@ jobs:
|
||||
|
||||
- name: Load saved Docker image
|
||||
if: steps.gatekeeper.outputs.skip == 'false'
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: docker-image
|
||||
path: /tmp/image
|
||||
|
||||
- name: Set Gitea status to PENDING
|
||||
if: steps.gatekeeper.outputs.skip == 'false'
|
||||
run: bash scripts/report-status.sh pending "Pushing to registry..." ci-docker-push
|
||||
run: |
|
||||
echo "===== gitea-ci-library - Docker Push | begin ====="
|
||||
bash scripts/report-status.sh pending "Pushing to registry..." ci-docker-push
|
||||
|
||||
- name: Push to Gitea Packages
|
||||
if: steps.gatekeeper.outputs.skip == 'false'
|
||||
@@ -258,6 +259,7 @@ jobs:
|
||||
tag-commit:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [check, push]
|
||||
if: always()
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -267,10 +269,15 @@ jobs:
|
||||
name: build-context
|
||||
path: /tmp/build-ctx
|
||||
|
||||
- name: Gatekeeper check
|
||||
- name: Verify Push Status
|
||||
id: gatekeeper
|
||||
run: |
|
||||
PUSH_RESULT="${{ needs.push.result }}"
|
||||
source /tmp/build-ctx/build.env
|
||||
if [ "$PUSH_RESULT" != "success" ]; then
|
||||
echo "gitea-ci-library - Push vaihe epäonnistui. Keskeytetään." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "${ARTIFACT_EXISTS}" = "true" ]; then
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
@@ -279,7 +286,9 @@ jobs:
|
||||
|
||||
- name: Set Gitea status to PENDING
|
||||
if: steps.gatekeeper.outputs.skip == 'false'
|
||||
run: bash scripts/report-status.sh pending "Creating tag..." ci-docker-tag
|
||||
run: |
|
||||
echo "===== gitea-ci-library - Create Tag | begin ====="
|
||||
bash scripts/report-status.sh pending "Creating tag..." ci-docker-tag
|
||||
|
||||
- name: Create git tag
|
||||
if: steps.gatekeeper.outputs.skip == 'false'
|
||||
|
||||
Reference in New Issue
Block a user