diff --git a/.gitea/workflows/builder.yaml b/.gitea/workflows/builder.yaml new file mode 100644 index 0000000..2147cbc --- /dev/null +++ b/.gitea/workflows/builder.yaml @@ -0,0 +1,61 @@ +name: Build & Push Builder Image + +on: + workflow_call: + inputs: + registry: + required: true + type: string + + username: + required: true + type: string + + secrets: + password: + required: true + + outputs: + tag: + description: "The built image reference" + value: ${{ jobs.builder.outputs.tag }} + +jobs: + builder: + runs-on: nix + + outputs: + tag: ${{ steps.build.outputs.tag }} + + env: + IMAGE_BASE: ${{ inputs.registry }}/${{ github.repository_owner }}/${{ github.event.repository.name }} + TAG_COMMIT: builder-${{ github.sha }} + TAG_MAIN: builder + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Log In to Registry + run: buildah login --username "${{ inputs.username }}" --password "${{ secrets.password }}" "${{ inputs.registry }}" + + - name: Build Builder Image + id: build + run: | + TAG_ARGS="--tag ${{ env.IMAGE_BASE }}:${{ env.TAG_COMMIT }}" + + if [[ "${{ github.ref_name }}" == "main" ]]; then + TAG_ARGS="$TAG_ARGS --tag ${{ env.IMAGE_BASE }}:${{ env.TAG_MAIN }}" + fi + + buildah build --layers --cache-to ${{ env.IMAGE_BASE }} --cache-from ${{ env.IMAGE_BASE }} -f .gitea/Containerfile $TAG_ARGS . + + echo "tag=${{ env.IMAGE_BASE }}:${{ env.TAG_COMMIT }}" >> $GITEA_OUTPUT + + - name: Push Builder Image + run: | + buildah push ${{ env.IMAGE_BASE }}:${{ env.TAG_COMMIT }} + + if [[ "${{ github.ref_name }}" == "main" ]]; then + buildah push ${{ env.IMAGE_BASE }}:${{ env.TAG_MAIN }} + fi