asdgas
This commit is contained in:
@@ -34,20 +34,46 @@ 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 "gitea-ci-library - Tunnistettu Major.Minor versio: $BASE_VERSION"
|
echo "Package.json version: $RAW_VERSION -> Base: $BASE_VERSION"
|
||||||
|
|
||||||
TAGS_JSON=$(curl -s -f -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
# Tehdään API-kutsu ilman -f lippua, jotta saadaan HTTP-koodi talteen debuggausta varten
|
||||||
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/tags")
|
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)
|
||||||
|
|
||||||
|
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
|
||||||
@@ -69,6 +95,9 @@ 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
|
||||||
|
|
||||||
- name: Upload build env artifact
|
- name: Upload build env artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
@@ -87,9 +116,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Set Gitea status to FAILURE
|
- name: Set Gitea status to FAILURE
|
||||||
if: failure()
|
if: failure()
|
||||||
run: bash scripts/report-status.sh failure "Check version FAILED" ci-check
|
run: |
|
||||||
|
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]
|
||||||
uses: niko/gitea-ci-library/.gitea/workflows/quality-gate.yml@main
|
uses: niko/gitea-ci-library/.gitea/workflows/quality-gate.yml@main
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
with:
|
with:
|
||||||
@@ -109,9 +142,11 @@ jobs:
|
|||||||
name: build-context
|
name: build-context
|
||||||
path: /tmp/build-ctx
|
path: /tmp/build-ctx
|
||||||
|
|
||||||
- name: Gatekeeper check
|
- name: Gatekeeper check & DEBUG
|
||||||
id: gatekeeper
|
id: gatekeeper
|
||||||
run: |
|
run: |
|
||||||
|
echo "=== DEBUG: BUILD JOB LITERALLY READS TIEDOSTO ==="
|
||||||
|
cat /tmp/build-ctx/build.env
|
||||||
source /tmp/build-ctx/build.env
|
source /tmp/build-ctx/build.env
|
||||||
if [ "${ARTIFACT_EXISTS}" = "true" ]; then
|
if [ "${ARTIFACT_EXISTS}" = "true" ]; then
|
||||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||||
@@ -121,9 +156,7 @@ 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: |
|
run: bash scripts/report-status.sh pending "Building Docker image..." ci-docker-build
|
||||||
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'
|
||||||
@@ -193,9 +226,7 @@ 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: |
|
run: bash scripts/report-status.sh pending "Pushing to registry..." ci-docker-push
|
||||||
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'
|
||||||
@@ -247,9 +278,7 @@ 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: |
|
run: bash scripts/report-status.sh pending "Creating tag..." ci-docker-tag
|
||||||
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