feat: implement quality-gate and publish-artifact pipelines
- Rename build-feature.yml → quality-gate.yml (merge-portti) - Create build_publish-artifact.yml: check → qg → build → push → tag - Add minimal Dockerfile for dogfood container build - Simplify quality-gate.yml cucumber job (remove prepare step, TOOL_OK) - Standardize test scripts in package.json for Docker-based local + CI runs - Update ci.yml: main branch uses build_publish-artifact.yml - Update docs/workflows.md: feature section rewritten with provider model - Add .gitignore entries for coverage/ and reports/
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
name: Build & Publish Artifact
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
env_json:
|
||||
required: true
|
||||
type: string
|
||||
bats-image:
|
||||
required: true
|
||||
type: string
|
||||
cucumber-node-image:
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
GITEA_TOKEN:
|
||||
required: true
|
||||
GIT_PAGES_PUBLISH_TOKEN:
|
||||
required: true
|
||||
|
||||
env:
|
||||
GITEA_API_URL: ${{ fromJson(inputs.env_json).GITEA_API_URL }}
|
||||
GIT_PAGES_URL: ${{ fromJson(inputs.env_json).GIT_PAGES_URL }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GIT_PAGES_PUBLISH_TOKEN: ${{ secrets.GIT_PAGES_PUBLISH_TOKEN }}
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
artifact_exists: ${{ steps.check.outputs.artifact_exists }}
|
||||
version: ${{ steps.check.outputs.version }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check existing artifact
|
||||
id: check
|
||||
run: |
|
||||
VERSION=$(jq -r '.version' package.json)
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
TAG=$(curl -s "$GITEA_API_URL/api/v1/repos/$GITHUB_REPOSITORY/tags" | \
|
||||
jq -r '.[] | select(.commit.sha == "'"$GITHUB_SHA"'") | .name' | head -1)
|
||||
if [ -n "$TAG" ]; then
|
||||
echo "artifact_exists=true" >> "$GITHUB_OUTPUT"
|
||||
echo "Commit already tagged as $TAG, skipping build"
|
||||
else
|
||||
echo "artifact_exists=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
quality-gate:
|
||||
needs: [check]
|
||||
if: needs.check.outputs.artifact_exists == 'false'
|
||||
uses: niko/gitea-ci-library/.gitea/workflows/quality-gate.yml@feture/docker-kyky
|
||||
secrets: inherit
|
||||
with:
|
||||
env_json: ${{ inputs.env_json }}
|
||||
bats-image: ${{ inputs.bats-image }}
|
||||
cucumber-node-image: ${{ inputs.cucumber-node-image }}
|
||||
|
||||
build:
|
||||
needs: [check, quality-gate]
|
||||
if: needs.check.outputs.artifact_exists == 'false'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Build container
|
||||
run: |
|
||||
docker build -t "minimal:${{ needs.check.outputs.version }}" .
|
||||
mkdir -p /tmp/image
|
||||
docker save "minimal:${{ needs.check.outputs.version }}" -o /tmp/image/artifact.tar
|
||||
|
||||
- name: Save Docker image for next job
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: docker-image
|
||||
path: /tmp/image/artifact.tar
|
||||
|
||||
push:
|
||||
needs: [check, build]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Load saved Docker image
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: docker-image
|
||||
path: /tmp/image
|
||||
|
||||
- name: Push to Gitea Packages
|
||||
run: |
|
||||
VERSION="${{ needs.check.outputs.version }}"
|
||||
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"
|
||||
|
||||
tag-commit:
|
||||
needs: [check, push]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create git tag
|
||||
run: |
|
||||
VERSION="${{ needs.check.outputs.version }}"
|
||||
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" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"tag_name\": \"$VERSION\",
|
||||
\"message\": \"Build #$GITHUB_RUN_NUMBER\",
|
||||
\"target\": \"$GITHUB_SHA\"
|
||||
}")
|
||||
|
||||
if [ "$HTTP_CODE" = "201" ]; then
|
||||
echo "Tag $VERSION created"
|
||||
elif [ "$HTTP_CODE" = "409" ]; then
|
||||
echo "Tag $VERSION already exists (parallel build won), skipping"
|
||||
else
|
||||
echo "Failed to create tag: HTTP $HTTP_CODE"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user