struj
This commit is contained in:
@@ -31,6 +31,8 @@ concurrency:
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
artifact_exists: ${{ steps.set-outputs.outputs.artifact_exists }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -69,6 +71,12 @@ jobs:
|
||||
echo "gitea-ci-library - Uusi vapaa versio: $FULL_VERSION"
|
||||
fi
|
||||
|
||||
- name: Set job outputs
|
||||
id: set-outputs
|
||||
run: |
|
||||
source /tmp/build-ctx/build.env
|
||||
echo "artifact_exists=$ARTIFACT_EXISTS" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload build env artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
@@ -102,10 +110,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
# needs: [check, quality-gate]
|
||||
needs: [check]
|
||||
# LÖYSÄTTY EHTO: Vaaditaan vain, että check-job meni onnistuneesti läpi.
|
||||
# Quality gate vastuulla on räjäyttää koko job jos se ei mene läpi!
|
||||
# Tämä sallii sen, että quality-gate voi olla Gitean muuttujissa tyhjä, eikä build-job enää ohitu (skip).
|
||||
if: always()
|
||||
# Skipataan koko build jos artefakti löytyy jo
|
||||
if: needs.check.outputs.artifact_exists != 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -115,6 +121,16 @@ jobs:
|
||||
name: build-context
|
||||
path: /tmp/build-ctx
|
||||
|
||||
- name: Check if build needed
|
||||
id: gatekeeper
|
||||
run: |
|
||||
source /tmp/build-ctx/build.env
|
||||
if [ "${ARTIFACT_EXISTS}" = "true" ]; then
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Set Gitea status to PENDING
|
||||
if: steps.gatekeeper.outputs.skip == 'false'
|
||||
run: |
|
||||
@@ -130,7 +146,7 @@ jobs:
|
||||
--label "git.commit=${{ github.sha }}" \
|
||||
--label "git.commitBy=${{ github.actor }}" \
|
||||
--label "build.date=${NOW}" \
|
||||
-t "minimal:${NEXT_VERSION}" .
|
||||
-t "gitea-ci-library-test-minimal:${NEXT_VERSION}" .
|
||||
|
||||
- name: Report status SUCCESS
|
||||
if: steps.gatekeeper.outputs.skip == 'false' && success()
|
||||
@@ -149,7 +165,7 @@ jobs:
|
||||
run: |
|
||||
source /tmp/build-ctx/build.env
|
||||
mkdir -p /tmp/image
|
||||
docker save "minimal:${NEXT_VERSION}" -o /tmp/image/artifact.tar
|
||||
docker save "gitea-ci-library-test-minimal:${NEXT_VERSION}" -o /tmp/image/artifact.tar
|
||||
|
||||
- name: Upload Docker image artifact
|
||||
if: steps.gatekeeper.outputs.skip == 'false' && success()
|
||||
@@ -161,7 +177,7 @@ jobs:
|
||||
push:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [check, build]
|
||||
if: always()
|
||||
if: needs.check.outputs.artifact_exists != 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -208,7 +224,7 @@ jobs:
|
||||
docker load -i /tmp/image/artifact.tar
|
||||
REGISTRY=$(echo "${{ gitea.server_url }}" | sed -e 's|^https://||' -e 's|^http://||')
|
||||
IMAGE="$REGISTRY/${{ gitea.repository }}:${NEXT_VERSION}"
|
||||
docker tag "minimal:$NEXT_VERSION" "$IMAGE"
|
||||
docker tag "gitea-ci-library-test-minimal:${NEXT_VERSION}" "$IMAGE"
|
||||
echo "$GITEA_TOKEN" | docker login "$REGISTRY" -u "${{ github.actor }}" --password-stdin
|
||||
docker push "$IMAGE"
|
||||
docker logout "$REGISTRY"
|
||||
@@ -228,7 +244,7 @@ jobs:
|
||||
tag-commit:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [check, push]
|
||||
if: always()
|
||||
if: needs.check.outputs.artifact_exists != 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
||||
Reference in New Issue
Block a user