Files
pterodactyl-discord-bot/.gitea/workflows/docker-build.yml
Eaven Kimura f84780ef63
All checks were successful
Docker Build and Push (Multi-architecture) / build-and-push (push) Successful in 21s
Fix CI/CD workflow
2025-09-16 13:57:31 +00:00

71 lines
2.5 KiB
YAML

name: Docker Build and Push (Multi-architecture)
on: [push]
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
driver-opts: |
image=moby/buildkit:latest
- name: Log in to registry
uses: docker/login-action@v2
with:
registry: ${{ vars.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push multi-arch image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=registry,ref=${{ vars.REGISTRY }}/${{ github.repository_owner }}/${{ vars.IMAGE_NAME }}:cache
cache-to: type=registry,ref=${{ vars.REGISTRY }}/${{ github.repository_owner }}/${{ vars.IMAGE_NAME }}:cache,mode=max
tags: |
${{ vars.REGISTRY }}/${{ github.repository_owner }}/${{ vars.IMAGE_NAME }}:latest
${{ vars.REGISTRY }}/${{ github.repository_owner }}/${{ vars.IMAGE_NAME }}:${{ github.sha }}
- name: Deploy to Portainer
run: |
COMPOSE_CONTENT=$(cat docker-compose.yml | base64 -w 0)
STACK_RESPONSE=$(curl -s -X GET \
"${{ vars.PORTAINER_URL }}/api/stacks" \
-H "X-API-Key: ${{ secrets.PORTAINER_API_KEY }}")
STACK_ID=$(echo $STACK_RESPONSE | jq -r '.[] | select(.Name == "${{ vars.STACK_NAME }}") | .Id')
curl -v -X PUT \
"${{ vars.PORTAINER_URL }}/api/stacks/$STACK_ID?endpointId=16" \
-H "X-API-Key: ${{ secrets.PORTAINER_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{
"stackFileContent": '"$COMPOSE_CONTENT"',
"pullImage": true,
"prune": true,
"env": [
{"name": "IMAGE_TAG", "value": "${{ github.sha }}"}
]
}'
echo "Deployment triggered for stack ID: $STACK_ID"
continue-on-error: false
- name: Verify deployment
run: |
echo "Deployment triggered successfully for commit ${{ github.sha }}"