Deploy Dokploy applications from GitHub and Gitea Actions

A dependency-free node20 action that triggers application.deploy or
compose.deploy, then follows the deployment to a terminal status so a
failed build fails the CI run. Snapshots the deployment list before
triggering, so a concurrent deployment is never mistaken for this one.

Optionally points the application at a freshly built image first, which
is what lets a workflow lint, test, push and deploy the same artifact.
This commit is contained in:
2026-08-09 03:37:35 +03:00
commit c23b44983b
20 changed files with 2778 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
# The same pipeline on Gitea Actions, pushing to Gitea's built-in registry.
#
# The only differences from the GitHub version are the registry host and the
# token: Gitea sets the same GITHUB_* variables, and the action reads them the
# same way. Requires a runner whose label provides Docker.
name: deploy
on:
push:
branches: [main]
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: false
env:
# Your Gitea instance, which is also its container registry.
REGISTRY: gitea.example.com
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci
- run: npm run lint
- run: npm test
build:
needs: check
runs-on: ubuntu-latest
outputs:
image: ${{ steps.meta.outputs.image }}
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
# Automatically provided by Gitea to every workflow run.
password: ${{ secrets.GITEA_TOKEN }}
- id: meta
run: |
image="$REGISTRY/$(echo "$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]'):${GITHUB_SHA::7}"
echo "image=$image" >> "$GITHUB_OUTPUT"
- uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.image }}
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: https://github.com/maxvojtkov/dokploy-deploy-action@v1
with:
host: ${{ secrets.DOKPLOY_HOST }}
api-key: ${{ secrets.DOKPLOY_API_KEY }}
project: shop
service: api
docker-image: ${{ needs.build.outputs.image }}
registry-url: ${{ env.REGISTRY }}
registry-username: ${{ secrets.REGISTRY_USERNAME }}
# A Gitea access token with read:package, not the ephemeral
# GITEA_TOKEN: Dokploy needs credentials that outlive this run.
registry-password: ${{ secrets.REGISTRY_TOKEN }}
timeout: 900