22
22
23
23
jobs :
24
24
push_to_registry :
25
- runs-on : ubuntu-22.04
25
+ runs-on : ubuntu-latest
26
26
if : ${{ github.event.workflow_run.conclusion != 'failure' }}
27
27
steps :
28
28
# Checkout latest or specific tag
@@ -50,87 +50,18 @@ jobs:
50
50
fi;
51
51
52
52
- name : Login to GitHub Container Registry
53
- uses : docker/login-action@v2
53
+ uses : docker/login-action@v3
54
54
with :
55
55
registry : ghcr.io
56
56
username : ${{ github.actor }}
57
57
password : ${{ secrets.GITHUB_TOKEN }}
58
58
59
59
# Build and push new docker image, skip for manual redeploy other than 'latest'
60
60
- name : Build and push Docker images
61
- uses : docker/build-push-action@v3
61
+ uses : docker/build-push-action@v6
62
62
if : ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }}
63
63
with :
64
64
file : Dockerfile
65
65
context : .
66
66
push : true
67
67
tags : ghcr.io/${{ env.image_repository_name }}:${{ env.TAG_NAME }}
68
-
69
- deploy_via_ssh :
70
- needs : push_to_registry
71
- runs-on : ubuntu-22.04
72
- if : ${{ github.event.workflow_run.conclusion != 'failure' }}
73
- steps :
74
- # Checkout latest or specific tag
75
- - name : checkout
76
- if : ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }}
77
- uses : actions/checkout@v3
78
- - name : checkout tag
79
- if : ${{ github.event.inputs.version != '' && github.event.inputs.version != 'latest' }}
80
- uses : actions/checkout@v3
81
- with :
82
- ref : refs/tags/${{ github.event.inputs.version }}
83
-
84
- - name : repository name fix and env
85
- run : |
86
- echo "image_repository_name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
87
- echo "domain=${{ secrets.DEPLOY_HOST }}" >> $GITHUB_ENV
88
- echo "letsencrypt_email=${{ secrets.LETSENCRYPT_EMAIL }}" >> $GITHUB_ENV
89
- echo "TAG_NAME=latest" >> $GITHUB_ENV
90
- if [ "${{ github.event.release.tag_name }}" != "" ]; then
91
- echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
92
- fi;
93
- if [ "${{ github.event.inputs.version }}" != "" ]; then
94
- echo "TAG_NAME=${{ github.event.inputs.version }}" >> $GITHUB_ENV
95
- fi;
96
-
97
- # Populate docker-compose.yml with variables from build process, including TAG_NAME.
98
- - name : docker-compose file prep
99
- uses : danielr1996/envsubst-action@1.0.0
100
- env :
101
- RELEASE_VERSION : ${{ env.TAG_NAME }}
102
- IMAGE_REPO : ${{ env.image_repository_name }}
103
- APP_NAME : ${{ github.event.repository.name }}
104
- HOST_DOMAIN : ${{ env.domain }}
105
- LETSENCRYPT_EMAIL : ${{ env.letsencrypt_email }}
106
- with :
107
- input : .deploy/docker-compose-template.yml
108
- output : .deploy/${{ github.event.repository.name }}-docker-compose.yml
109
-
110
- # Copy only the docker-compose.yml to remote server home folder
111
- - name : copy compose file via scp
112
- uses : appleboy/scp-action@v0.1.3
113
- with :
114
- host : ${{ secrets.DEPLOY_HOST }}
115
- username : ${{ secrets.DEPLOY_USERNAME }}
116
- port : 22
117
- key : ${{ secrets.DEPLOY_KEY }}
118
- source : " .deploy/${{ github.event.repository.name }}-docker-compose.yml"
119
- target : " ~/"
120
-
121
- # Deploy Docker image with ServiceStack application using `docker compose up` remotely
122
- - name : remote docker-compose up via ssh
123
- uses : appleboy/ssh-action@v0.1.5
124
- env :
125
- APPTOKEN : ${{ secrets.GITHUB_TOKEN }}
126
- USERNAME : ${{ secrets.DEPLOY_USERNAME }}
127
- with :
128
- host : ${{ secrets.DEPLOY_HOST }}
129
- username : ${{ secrets.DEPLOY_USERNAME }}
130
- key : ${{ secrets.DEPLOY_KEY }}
131
- port : 22
132
- envs : APPTOKEN,USERNAME
133
- script : |
134
- echo $APPTOKEN | docker login ghcr.io -u $USERNAME --password-stdin
135
- docker-compose -f ~/.deploy/${{ github.event.repository.name }}-docker-compose.yml pull
136
- docker-compose -f ~/.deploy/${{ github.event.repository.name }}-docker-compose.yml up -d
0 commit comments