From 95d36bf24fe8f3ec5576ac6b3cc06e472f97f818 Mon Sep 17 00:00:00 2001 From: UltimateCoder Date: Fri, 27 Mar 2026 22:31:39 +0000 Subject: [PATCH] Add .gitea/workflows/docker.yaml --- .gitea/workflows/docker.yaml | 80 ++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .gitea/workflows/docker.yaml diff --git a/.gitea/workflows/docker.yaml b/.gitea/workflows/docker.yaml new file mode 100644 index 0000000..1c98c27 --- /dev/null +++ b/.gitea/workflows/docker.yaml @@ -0,0 +1,80 @@ +name: Docker build & push + +on: + workflow_call: + inputs: + DockerImageDomain: + description: 'Docker registry domain, e.g. registry.example.com' + required: true + type: string + DockerImageOrganisation: + description: 'Namespace / organisation in the registry' + required: true + type: string + DockerImageName: + description: 'Image name' + required: true + type: string + DockerFilePath: + description: 'Path to the Dockerfile' + required: false + type: string + default: ./Dockerfile + DockerImageVersion: + description: 'Value used for the VERSION build-arg' + required: true + type: string + secrets: + DockerUsername: + description: 'Registry username' + required: true + default: "DOCKER_USERNAME" + DockerPassword: + description: 'Registry password / token' + required: true + default: "DOCKER_PASSWORD" + +jobs: + build-and-push: + runs-on: ubuntu-latest + + env: + IMAGE: ${{ inputs.DockerImageDomain }}/${{ inputs.DockerImageOrganisation }}/${{ inputs.DockerImageName }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build Image + run: | + docker build \ + -t "$IMAGE:latest" \ + . \ + --file "${{ inputs.DockerFilePath }}" \ + --build-arg VERSION=${{ inputs.DockerImageVersion }} + + - name: Docker Release - Master + if: startsWith(github.ref, 'refs/heads/master') + run: | + docker image tag "$IMAGE:latest" "$IMAGE:${GITHUB_REF_NAME}" + + - name: Docker Release - Dev + if: startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/feature/') + run: | + docker image tag "$IMAGE:latest" "$IMAGE:${GITHUB_REF_NAME}" + + - name: Docker Release - Tagged + if: startsWith(github.ref, 'refs/tags/') + run: | + docker image tag "$IMAGE:latest" "$IMAGE:${GITHUB_REF_NAME}" + + + - name: Docker Push + if: startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/tags/') + env: + USERNAME: ${{ secrets.DockerUsername }} + PASSWORD: ${{ secrets.DockerPassword }} + run: | + echo "$PASSWORD" | docker login "${{ inputs.DockerImageDomain }}" -u "$USERNAME" --password-stdin + docker push -a "$IMAGE" + docker system prune --all --force --filter until=6h