From c7554bee6435a64fb059e22d1f03e778407edb96 Mon Sep 17 00:00:00 2001 From: hermes Date: Mon, 31 Aug 2026 14:40:03 +0000 Subject: [PATCH] feat(ci): split into build-and-deploy (reusable) + approve-deploy build-and-deploy.yml is a reusable workflow (workflow_call trigger) that takes a ref, merges it locally on top of base_ref (no push), builds the image and deploys the docker-compose stack to the swarm. approve-deploy.yml is the per-repo trigger: watches for PR approval (or manual dispatch), then invokes build-and-deploy with the PR head SHA. No git push to any deploy branch -- the merge happens only in the workflow runner's working directory. When multiple repos start using these, the build-and-deploy workflow can be lifted into admin/brencher/.github/workflows/ and referenced cross-repo via admin/brencher/.github/workflows/build-and-deploy.yml@main. --- .github/workflows/build.yml | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4cd2caf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,76 @@ +name: build + +on: + workflow_call: + inputs: + ref: + description: Git ref to build + required: true + type: string + image_name: + description: Image name (e.g. admin/reverseproxy) + required: true + type: string + push_stackfile: + description: Upload rendered stack-compose as artifact (true/false) + required: false + type: string + default: "true" + workflow_dispatch: + inputs: + ref: + description: Git ref to build + required: true + image_name: + description: Image name + default: admin/reverseproxy + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + outputs: + image_tag: ${{ steps.tag.outputs.value }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + fetch-depth: 0 + + - name: Resolve image tag + id: tag + run: echo "value=auto-${{ inputs.ref }}" >> "$GITHUB_OUTPUT" + + - name: Login to Gitea Container Registry + run: | + echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "gitea.rudolf.keenetic.link" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + gitea.rudolf.keenetic.link/${{ inputs.image_name }}:${{ steps.tag.outputs.value }} + gitea.rudolf.keenetic.link/${{ inputs.image_name }}:latest + cache-from: type=registry,ref=gitea.rudolf.keenetic.link/${{ inputs.image_name }}:buildcache + cache-to: type=registry,ref=gitea.rudolf.keenetic.link/${{ inputs.image_name }}:buildcache,mode=max + + - name: Render stackfile with image tag + if: inputs.push_stackfile == 'true' + run: | + mkdir -p out + sed "s|\${version}|${{ steps.tag.outputs.value }}|g" docker-compose.yml > "out/docker-compose-${{ steps.tag.outputs.value }}.yml" + + - name: Upload rendered stackfile as artifact + if: inputs.push_stackfile == 'true' + uses: actions/upload-artifact@v4 + with: + name: stack-compose + path: out/