Skip to content

Instantly share code, notes, and snippets.

@badsyntax
Created June 18, 2021 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badsyntax/c6eee93cb6604358fd5931832c52bc48 to your computer and use it in GitHub Desktop.
Save badsyntax/c6eee93cb6604358fd5931832c52bc48 to your computer and use it in GitHub Desktop.
portainer docker swarm CD (GitHub Actions)
name: Deploy
on:
workflow_dispatch:
push:
branches:
- master
jobs:
publish-docker-image:
name: Publish docker image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2.3.4
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and push docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/arm64 # note we're deploying to a raspberry pi
tags: ghcr.io/${{ github.repository }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
deploy:
name: Deploy app
runs-on: ubuntu-20.04
needs: [publish-docker-image]
steps:
- name: Deploy
run: |
curl --fail -X POST "$DEPLOY_ENDPOINT" || exit 1
env:
DEPLOY_ENDPOINT: '${{ secrets.DEPLOY_ENDPOINT }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment