diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml new file mode 100644 index 0000000..dff1b7f --- /dev/null +++ b/.gitea/workflows/docker.yml @@ -0,0 +1,75 @@ +name: Docker + +on: + push: + branches: + - main + tags: + - "v*" + workflow_dispatch: + +env: + IMAGE_NAME: fsadmin/md-to-html + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Prepare tags + id: meta + shell: sh + run: | + set -eu + + if [ -z "${{ vars.REGISTRY }}" ]; then + echo "::error::Set the REGISTRY repository variable to your Gitea registry host." + exit 1 + fi + + image="${{ vars.REGISTRY }}/${IMAGE_NAME}" + short_sha="$(printf '%s' "${GITHUB_SHA}" | cut -c1-12)" + + { + echo "image=${image}" + echo "tags<> "${GITHUB_OUTPUT}" + + - name: Login to registry + run: | + printf '%s' "${{ secrets.REGISTRY_PASSWORD }}" \ + | docker login "${{ vars.REGISTRY }}" \ + --username "${{ secrets.REGISTRY_USERNAME }}" \ + --password-stdin + + - name: Build and push image + env: + DOCKER_BUILDKIT: "1" + run: | + set -eu + + tags="" + while IFS= read -r tag; do + tags="${tags} -t ${tag}" + done <<'EOF' + ${{ steps.meta.outputs.tags }} + EOF + + docker build ${tags} . + + while IFS= read -r tag; do + docker push "${tag}" + done <<'EOF' + ${{ steps.meta.outputs.tags }} + EOF