Files
Sergey Filkin e6ff59c75b
Docker / build (push) Successful in 39s
Fix code block styling and add deploy webhook
2026-04-30 19:52:19 +03:00

88 lines
2.1 KiB
YAML

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<<EOF"
echo "${image}:${short_sha}"
if [ "${GITHUB_REF}" = "refs/heads/main" ]; then
echo "${image}:latest"
fi
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
echo "${image}:${GITHUB_REF_NAME}"
fi
echo "EOF"
} >> "${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
- name: Trigger Dokploy deployment
if: github.ref == 'refs/heads/main'
run: |
set -eu
if [ -z "${{ secrets.DOKPLOY_WEBHOOK_URL }}" ]; then
echo "::error::Set the DOKPLOY_WEBHOOK_URL repository secret."
exit 1
fi
curl -fsS -X POST "${{ secrets.DOKPLOY_WEBHOOK_URL }}"