2222
2323jobs :
2424 push_to_registry :
25- runs-on : ubuntu-22.04
25+ runs-on : ubuntu-latest
2626 if : ${{ github.event.workflow_run.conclusion != 'failure' }}
2727 steps :
2828 # Checkout latest or specific tag
@@ -50,87 +50,18 @@ jobs:
5050 fi;
5151
5252 - name : Login to GitHub Container Registry
53- uses : docker/login-action@v2
53+ uses : docker/login-action@v3
5454 with :
5555 registry : ghcr.io
5656 username : ${{ github.actor }}
5757 password : ${{ secrets.GITHUB_TOKEN }}
5858
5959 # Build and push new docker image, skip for manual redeploy other than 'latest'
6060 - name : Build and push Docker images
61- uses : docker/build-push-action@v3
61+ uses : docker/build-push-action@v6
6262 if : ${{ github.event.inputs.version == '' || github.event.inputs.version == 'latest' }}
6363 with :
6464 file : Dockerfile
6565 context : .
6666 push : true
6767 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/[email protected] 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- 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- 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