Initial commit
This commit is contained in:
66
.gitea/workflows/docker-publish.yml
Normal file
66
.gitea/workflows/docker-publish.yml
Normal file
@@ -0,0 +1,66 @@
|
||||
name: Reusable Docker Publish
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
image_name:
|
||||
required: true
|
||||
type: string
|
||||
dockerfile_path:
|
||||
type: string
|
||||
default: "."
|
||||
secrets:
|
||||
REGISTRY_USERNAME: { required: true }
|
||||
REGISTRY_PASSWORD: { required: true }
|
||||
DOCKER_REGISTRY: { required: true }
|
||||
NTFY_TOPIC: { required: true }
|
||||
NTFY_TOKEN: { required: true }
|
||||
NTFY_SERVER: { required: true }
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: gitea.tech-buddy.at/bitbuddydev/gitea_runner_python314:dev-bda315b82bb23d83065b77d91fedf0e20d9accf1
|
||||
credentials:
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Extract Tags
|
||||
id: vars
|
||||
shell: bash
|
||||
run: |
|
||||
SHA_SHORT="$(git rev-parse --short HEAD)"
|
||||
FULL_IMAGE="${{ secrets.DOCKER_REGISTRY }}/${{ inputs.image_name }}"
|
||||
TAGS="-t ${FULL_IMAGE}:${SHA_SHORT}"
|
||||
|
||||
if echo "${{ gitea.ref }}" | grep -q '^refs/tags/v'; then
|
||||
VERSION="${{ gitea.ref_name }}"
|
||||
VERSION="${VERSION#v}"
|
||||
MAJOR="$(echo "$VERSION" | cut -d. -f1)"
|
||||
MINOR="$(echo "$VERSION" | cut -d. -f1,2)"
|
||||
TAGS="${TAGS} -t ${FULL_IMAGE}:latest -t ${FULL_IMAGE}:${VERSION} -t ${FULL_IMAGE}:${MINOR} -t ${FULL_IMAGE}:${MAJOR}"
|
||||
fi
|
||||
|
||||
echo "docker_tags=${TAGS}" >> "$GITEA_OUTPUT"
|
||||
echo "full_image=${FULL_IMAGE}" >> "$GITEA_OUTPUT"
|
||||
|
||||
- name: Docker Login
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${{ secrets.DOCKER_REGISTRY }}" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
||||
|
||||
- name: Build and Push
|
||||
run: |
|
||||
export DOCKER_BUILDKIT=1
|
||||
docker build ${{ steps.vars.outputs.docker_tags }} ${{ inputs.dockerfile_path }}
|
||||
|
||||
IMAGE="${{ steps.vars.outputs.full_image }}"
|
||||
for part in ${{ steps.vars.outputs.docker_tags }}; do
|
||||
if [[ "$part" == "${IMAGE}:"* ]]; then
|
||||
docker push "$part"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user