Add .gitea/workflows/docker.yaml
This commit is contained in:
@@ -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
|
||||||
Reference in New Issue
Block a user