Created
June 18, 2021 05:33
-
-
Save badsyntax/c6eee93cb6604358fd5931832c52bc48 to your computer and use it in GitHub Desktop.
portainer docker swarm CD (GitHub Actions)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
jobs: | |
publish-docker-image: | |
name: Publish docker image | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/[email protected] | |
- 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