Files
amare/.gitea/workflows/deploy-staging.yml
manoel freitas 26a68e1823
All checks were successful
CI / static (push) Successful in 2m38s
CI / unit (push) Successful in 3m40s
CI / feature (push) Successful in 2m55s
CI / container (push) Successful in 1m11s
CI / browser (push) Successful in 4m22s
fix: restaurar deploy-staging via workflow_run (Gitea ≥1.25)
Remove job/reusable workflow do CI. Staging volta a ser workflow
separado após CI; 1.24 não implementava o trigger.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-12 16:01:56 -03:00

90 lines
2.6 KiB
YAML

name: Deploy staging
# Requires Gitea >= 1.25 for workflow_run (1.24.x has no trigger match).
on:
workflow_run:
workflows:
- CI
- ci.yml
types:
- completed
branches:
- main
workflow_dispatch:
permissions:
contents: read
packages: write
concurrency:
group: deploy-staging
cancel-in-progress: false
env:
REGISTRY: git.hellomanoel.com
IMAGE_NAME: ${{ gitea.repository }}
jobs:
deploy:
name: publish-and-deploy-staging
if: >-
gitea.event_name == 'workflow_dispatch' ||
(gitea.event.workflow_run.conclusion == 'success' &&
gitea.event.workflow_run.event == 'push' &&
gitea.event.workflow_run.head_branch == 'main')
runs-on: ubuntu-latest
steps:
- name: Checkout deployed SHA
uses: actions/checkout@v4
with:
ref: ${{ gitea.event.workflow_run.head_sha || gitea.sha }}
- name: Set image metadata
id: meta
run: |
SHA="${{ gitea.event.workflow_run.head_sha || gitea.sha }}"
SHORT_SHA="${SHA:0:7}"
IMAGE="${REGISTRY}/${IMAGE_NAME}"
IMAGE="$(echo "$IMAGE" | tr '[:upper:]' '[:lower:]')"
echo "sha=${SHA}" >> "$GITHUB_OUTPUT"
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
- name: Log in to Gitea registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
# Gitea's GITEA_TOKEN cannot push OCI packages (gitea#23642); a PAT
# with read:package/write:package scopes is required instead.
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PAT }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push SHA + staging tags
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.sha }}
${{ steps.meta.outputs.image }}:staging
- name: Deploy staging on Dokploy
env:
DOKPLOY_URL: ${{ secrets.DOKPLOY_URL }}
DOKPLOY_API_KEY: ${{ secrets.DOKPLOY_API_KEY }}
DOKPLOY_COMPOSE_ID: ${{ secrets.DOKPLOY_STAGING_COMPOSE_ID }}
DEPLOY_TITLE: "staging ${{ steps.meta.outputs.short_sha }}"
run: |
chmod +x scripts/deploy/dokploy-deploy.sh
./scripts/deploy/dokploy-deploy.sh
- name: Smoke staging
env:
SMOKE_BASE_URL: ${{ secrets.STAGING_URL }}
run: |
chmod +x scripts/deploy/smoke.sh
./scripts/deploy/smoke.sh