Skip to content

Commit 74a522d

Browse files
authored
feat: create docker image
1 parent 395fa4a commit 74a522d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/docker-image.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: docker-image
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
# on:
8+
# pull_request:
9+
# release:
10+
# push:
11+
# branches:
12+
# - 'main'
13+
14+
jobs:
15+
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: Build image
24+
run: docker build --platform linux/amd64 -t myimage .
25+
26+
- name: Log into registry
27+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
28+
29+
- name: Push image
30+
run: |
31+
IMAGE_ID=ghcr.io/${{ github.repository }}
32+
33+
# Change all uppercase to lowercase
34+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
35+
36+
VERSION=latest
37+
if [[ $GITHUB_REF == refs/tags/* ]]; then
38+
VERSION=${GITHUB_REF#refs/tags/}
39+
fi
40+
41+
docker tag myimage $IMAGE_ID:$VERSION
42+
docker push $IMAGE_ID:$VERSION

0 commit comments

Comments
 (0)