File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Image build
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ tags :
8
+ - v*
9
+ pull_request :
10
+
11
+ env :
12
+ IMAGE_NAME : web-app
13
+ MONGO_DB_ADMIN_PASSWD : ${{ secrets.MONGO_DB_ADMIN_PASSWD }}
14
+ MONGO_DB_ADMIN_USER : ${{ secrets.MONGO_DB_ADMIN_USER }}
15
+
16
+ jobs :
17
+
18
+ push :
19
+ runs-on : ubuntu-latest
20
+ permissions :
21
+ package : write
22
+ contents : read
23
+
24
+ steps :
25
+ - uses : actions/checkout@v4
26
+ - name : Build image
27
+ run : docker compose build app
28
+ - name : Tag with Image
29
+ run : docker tag web-app:latest $IMAGE_NAME:$GITHUB_SHA
30
+ - name : Log in to registry
31
+ run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
32
+ - name : Push to registry
33
+ run : |
34
+ IMAGE_ID=ghcr.io/leetcode-golang-classroom/$IMAGE_NAME
35
+ IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
36
+ VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
37
+ [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
38
+ [ "$VERSION" == "main" ] && VERSION=latest
39
+ echo IMAGE_ID=$IMAGE_ID
40
+ echo VERSION=$VERSION
41
+ docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
42
+ docker push $IMAGE_ID:$VERSION
You can’t perform that action at this time.
0 commit comments