sdgsf
This commit is contained in:
@@ -34,46 +34,20 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- 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
|
- name: Set Gitea status to PENDING
|
||||||
run: |
|
run: |
|
||||||
echo "===== gitea-ci-library - Check existing artifact | begin ====="
|
echo "===== gitea-ci-library - Check existing artifact | begin ====="
|
||||||
bash scripts/report-status.sh pending "Checking version..." ci-check
|
bash scripts/report-status.sh pending "Checking version..." ci-check
|
||||||
|
|
||||||
- name: Check existing artifact and calculate version
|
- name: Check existing artifact and calculate version
|
||||||
id: run_check
|
|
||||||
run: |
|
run: |
|
||||||
echo "=== DEBUG: STARTING API CALL ==="
|
|
||||||
RAW_VERSION=$(jq -r '.version' package.json)
|
RAW_VERSION=$(jq -r '.version' package.json)
|
||||||
BASE_VERSION=$(echo "$RAW_VERSION" | cut -d'.' -f1-2)
|
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
|
TAGS_JSON=$(curl -s -f -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
HTTP_RESPONSE=$(curl -s -w "%{http_code}" -H "Authorization: token $GITEA_TOKEN" \
|
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/tags")
|
||||||
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/tags" -o /tmp/tags.json)
|
|
||||||
|
|
||||||
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)
|
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
|
mkdir -p /tmp/build-ctx
|
||||||
@@ -95,10 +69,6 @@ jobs:
|
|||||||
echo "gitea-ci-library - Uusi vapaa versio: $FULL_VERSION"
|
echo "gitea-ci-library - Uusi vapaa versio: $FULL_VERSION"
|
||||||
fi
|
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
|
- name: Upload build env artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -117,11 +87,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Set Gitea status to FAILURE
|
- name: Set Gitea status to FAILURE
|
||||||
if: failure()
|
if: failure()
|
||||||
run: |
|
run: bash scripts/report-status.sh failure "Check version FAILED" ci-check
|
||||||
echo "===== gitea-ci-library - Check existing artifact | fail ====="
|
|
||||||
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:
|
quality-gate:
|
||||||
needs: [check]
|
needs: [check]
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/quality-gate.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/quality-gate.yml@main
|
||||||
@@ -134,22 +101,46 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [check, quality-gate]
|
needs: [check, quality-gate]
|
||||||
|
# PAKOTETAAN KÄYNTIIN: always() ohittaa Gitean dynaamisen skippausbugin
|
||||||
|
if: always()
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- 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
|
- name: Download build env
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: build-context
|
name: build-context
|
||||||
path: /tmp/build-ctx
|
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
|
id: gatekeeper
|
||||||
run: |
|
run: |
|
||||||
echo "=== DEBUG: BUILD JOB LITERALLY READS TIEDOSTO ==="
|
QG_RESULT="${{ needs.quality-gate.result }}"
|
||||||
cat /tmp/build-ctx/build.env
|
|
||||||
source /tmp/build-ctx/build.env
|
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"
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||||
@@ -157,7 +148,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Set Gitea status to PENDING
|
- name: Set Gitea status to PENDING
|
||||||
if: steps.gatekeeper.outputs.skip == 'false'
|
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
|
- name: Build container
|
||||||
if: steps.gatekeeper.outputs.skip == 'false'
|
if: steps.gatekeeper.outputs.skip == 'false'
|
||||||
@@ -191,7 +184,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload Docker image artifact
|
- name: Upload Docker image artifact
|
||||||
if: steps.gatekeeper.outputs.skip == 'false' && success()
|
if: steps.gatekeeper.outputs.skip == 'false' && success()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: docker-image
|
name: docker-image
|
||||||
path: /tmp/image/artifact.tar
|
path: /tmp/image/artifact.tar
|
||||||
@@ -199,6 +192,7 @@ jobs:
|
|||||||
push:
|
push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [check, build]
|
needs: [check, build]
|
||||||
|
if: always()
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -208,10 +202,15 @@ jobs:
|
|||||||
name: build-context
|
name: build-context
|
||||||
path: /tmp/build-ctx
|
path: /tmp/build-ctx
|
||||||
|
|
||||||
- name: Gatekeeper check
|
- name: Verify Build Status
|
||||||
id: gatekeeper
|
id: gatekeeper
|
||||||
run: |
|
run: |
|
||||||
|
BUILD_RESULT="${{ needs.build.result }}"
|
||||||
source /tmp/build-ctx/build.env
|
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
|
if [ "${ARTIFACT_EXISTS}" = "true" ]; then
|
||||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
@@ -220,14 +219,16 @@ jobs:
|
|||||||
|
|
||||||
- name: Load saved Docker image
|
- name: Load saved Docker image
|
||||||
if: steps.gatekeeper.outputs.skip == 'false'
|
if: steps.gatekeeper.outputs.skip == 'false'
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: docker-image
|
name: docker-image
|
||||||
path: /tmp/image
|
path: /tmp/image
|
||||||
|
|
||||||
- name: Set Gitea status to PENDING
|
- name: Set Gitea status to PENDING
|
||||||
if: steps.gatekeeper.outputs.skip == 'false'
|
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
|
- name: Push to Gitea Packages
|
||||||
if: steps.gatekeeper.outputs.skip == 'false'
|
if: steps.gatekeeper.outputs.skip == 'false'
|
||||||
@@ -258,6 +259,7 @@ jobs:
|
|||||||
tag-commit:
|
tag-commit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [check, push]
|
needs: [check, push]
|
||||||
|
if: always()
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -267,10 +269,15 @@ jobs:
|
|||||||
name: build-context
|
name: build-context
|
||||||
path: /tmp/build-ctx
|
path: /tmp/build-ctx
|
||||||
|
|
||||||
- name: Gatekeeper check
|
- name: Verify Push Status
|
||||||
id: gatekeeper
|
id: gatekeeper
|
||||||
run: |
|
run: |
|
||||||
|
PUSH_RESULT="${{ needs.push.result }}"
|
||||||
source /tmp/build-ctx/build.env
|
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
|
if [ "${ARTIFACT_EXISTS}" = "true" ]; then
|
||||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
@@ -279,7 +286,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Set Gitea status to PENDING
|
- name: Set Gitea status to PENDING
|
||||||
if: steps.gatekeeper.outputs.skip == 'false'
|
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
|
- name: Create git tag
|
||||||
if: steps.gatekeeper.outputs.skip == 'false'
|
if: steps.gatekeeper.outputs.skip == 'false'
|
||||||
|
|||||||
Reference in New Issue
Block a user