Some checks failed
Docker Build and Push (Multi-architecture) / build-and-push (push) Failing after 27s
65 lines
2.1 KiB
YAML
65 lines
2.1 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
|
|
id: deploy
|
|
uses: fjogeleit/http-request-action@v1
|
|
with:
|
|
url: ${{ vars.PORTAINER_URL }}/api/stacks/${{ vars.STACK_ID }}/git/redeploy
|
|
method: POST
|
|
customHeaders: '{
|
|
"X-API-Key": "${{ secrets.PORTAINER_API_KEY }}",
|
|
"Content-Type": "application/json"
|
|
}'
|
|
data: '{
|
|
"env": [
|
|
{"name": "IMAGE_TAG", "value": "${{ github.sha }}"},
|
|
{"name": "DEPLOY_TIMESTAMP", "value": "${{ github.run_id }}"}
|
|
],
|
|
"prune": true,
|
|
"pullImage": true
|
|
}'
|
|
continue-on-error: false
|
|
|
|
- name: Verify deployment
|
|
run: |
|
|
echo "Deployment triggered successfully for commit ${{ github.sha }}" |