-
Notifications
You must be signed in to change notification settings - Fork 8
49 lines (37 loc) · 1.63 KB
/
default__deploy-docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Deploy Docker
on:
workflow_run:
workflows:
- 'Build and push Docker - disabled'
types:
- completed
workflow_dispatch:
env:
IMAGE_NAME_WITH_TAG: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
jobs:
deploy:
name: Deploy image from Dockerhub to remote host with ssh
runs-on: ubuntu-latest
steps:
- name: Deploy latest image
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USERNAME }}
key: ${{ secrets.REMOTE_KEY_ED25519 }}
port: ${{ secrets.REMOTE_PORT }}
# don't stop on errors
script_stop: false
script: |
cd /home/ubuntu/traefik-proxy/apps/nmc-docker
# Docker login for private image
echo "${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin"
echo "Old image tag: $(docker inspect --format '{{ index .RepoTags 0 }}' ${{ env.IMAGE_NAME_WITH_TAG }})"
echo "Old image hash: $(docker inspect --format '{{ index .RepoDigests 0 }}' ${{ env.IMAGE_NAME_WITH_TAG }})"
docker compose down
docker image rm ${{ env.IMAGE_NAME_WITH_TAG }} || true
docker compose up -d
echo "New image tag: $(docker inspect --format '{{ index .RepoTags 0 }}' ${{ env.IMAGE_NAME_WITH_TAG }})"
echo "New image hash: $(docker inspect --format '{{ index .RepoDigests 0 }}' ${{ env.IMAGE_NAME_WITH_TAG }})"
# remove dangling images, optional
# docker image prune -af