-
Notifications
You must be signed in to change notification settings - Fork 5
79 lines (70 loc) · 2.8 KB
/
publish.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Publish Docker Image
on:
workflow_dispatch:
push:
branches: main
jobs:
publish:
name: Publish Docker Image to ghcr.io
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Extract version number
run: |
VERSION=$(grep -oP -m 1 '(?<=^## r)\d+' CHANGELOG.md)
if [[ $VERSION = "" ]]; then
echo "No version found in CHANGELOG.md"
exit 1
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create Docker Image tags
run: |
TAGS="ghcr.io/${{ github.repository }}:dev"
if docker manifest inspect ghcr.io/${{ github.repository }}:0.0.$VERSION > /dev/null 2>&1; then
echo "Image with version (0.0.$VERSION) already exists in registry"
echo "Publishing a dev image.."
else
echo "Image with version (0.0.$VERSION) does not exist in the registry yet"
echo "Publishing a release and a dev image.."
echo "IS_RELEASE=true" >> $GITHUB_ENV
TAGS="${TAGS},\
ghcr.io/${{ github.repository }}:0.0.${{ env.VERSION }},\
ghcr.io/${{ github.repository }}:latest"
fi
echo "TAGS=${TAGS}" >> $GITHUB_ENV
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ env.TAGS }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
- name: Update release container on server
if: env.IS_RELEASE == 'true'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_PRIVKEY }}
# this relies on a specific custom update script that is installed on the
# server that currently hosts sheltupdate. Adjust as needed.
script: ~/update.sh sheltupdate
- name: Update staging container on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_PRIVKEY }}
script: ~/update.sh sheltupdate-staging