Files
ascii-art-app/.gitea/workflows/deploy.yml
T
Ricardo Mancinas 947ad44da5
Build and Deploy / Build Image (push) Failing after 9s
Build and Deploy / Deploy to Portainer (push) Has been skipped
Fix workflow to match gitea-actions-portainer-deploy skill pattern
2026-07-11 20:59:36 -07:00

72 lines
2.0 KiB
YAML

name: Build and Deploy
on:
push:
branches: [main]
paths:
- "**"
- "Dockerfile"
- "docker-compose.yml"
workflow_dispatch:
env:
REGISTRY: git.mancinas.io
REPO_NAME: ascii-art-app
jobs:
build:
name: Build Image
runs-on: docker
container:
image: docker:27-dind
options: --privileged
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.REPO_NAME }}
tags: |
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
deploy:
name: Deploy to Portainer
needs: [build]
runs-on: docker
container:
image: node:18-alpine
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
steps:
- uses: actions/checkout@v4
- uses: cssnr/portainer-stack-deploy-action@v1
with:
url: ${{ secrets.PORTAINER_URL }}
token: ${{ secrets.PORTAINER_API_KEY }}
name: ${{ secrets.PORTAINER_STACK_NAME }}
file: docker-compose.yml
type: file
pull_image: true
endpoint_id: ${{ secrets.PORTAINER_ENDPOINT_ID }}
env_data: |
{
"IMAGE": "${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.REPO_NAME }}:latest"
}