Skip to content

Commit d342e7c

Browse files
authored
Add push to ghcr for docker image
1 parent 010cf60 commit d342e7c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Node.js CI - Dockge
22

3+
env:
4+
IMAGE_NAME: Dockge
5+
36
on:
47
push:
58
branches: [master]
@@ -59,5 +62,22 @@ jobs:
5962

6063
- name: Build
6164
run: pnpm run build:frontend
62-
# more things can be add later like tests etc..
65+
66+
- name: Build image
67+
run: docker build . --file docker/Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
68+
69+
- name: Log in to registry
70+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
71+
72+
- name: Push image
73+
run: |
74+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
75+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
76+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
77+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
78+
[ "$VERSION" == "main" ] && VERSION=latest
79+
echo IMAGE_ID=$IMAGE_ID
80+
echo VERSION=$VERSION
81+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
82+
docker push $IMAGE_ID:$VERSION
6383

0 commit comments

Comments
 (0)