@@ -2,55 +2,44 @@ name: ci
2
2
3
3
on :
4
4
push :
5
- branches :
6
- - main
5
+ branches : [main]
7
6
pull_request :
8
7
9
- # tags:
10
- # - v*
11
-
12
8
env :
13
9
IMAGE_NAME : mdt-dialout-collector
14
10
15
11
jobs :
16
- ci :
12
+ build :
13
+ runs-on : ubuntu-latest
14
+ steps :
15
+ - uses : actions/checkout@v3
16
+
17
+ - name : Build image
18
+ run : docker build docker --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
19
+
20
+ push :
21
+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
22
+ needs : build
17
23
runs-on : ubuntu-latest
18
24
permissions :
19
25
packages : write
20
26
contents : read
21
-
22
27
steps :
23
28
- uses : actions/checkout@v3
24
29
25
- - name : Build image
30
+ - name : Build image again
26
31
run : docker build docker --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
27
32
28
- - name : Log into registry
29
- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
30
- run : |
31
- TOKEN="$GHCR_PAT"
32
- if [ -z "$TOKEN" ]; then
33
- echo "GHCR_PAT is not available"
34
- exit 1
35
- fi
36
- echo "$TOKEN" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
33
+ - name : Log in to GHCR
37
34
env :
38
35
GHCR_PAT : ${{ secrets.GHCR_PAT }}
36
+ run : |
37
+ echo "$GHCR_PAT" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
39
38
40
39
- name : Push image
41
- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
42
40
run : |
43
41
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
44
-
45
- # Change all uppercase to lowercase
46
- IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
47
- # Strip git ref prefix from version
48
- VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
49
- # Strip "v" prefix from tag name
50
- #[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
51
- # Use Docker `latest` tag convention
52
- [ "$VERSION" == "main" ] && VERSION=latest
53
- echo IMAGE_ID=$IMAGE_ID
54
- echo VERSION=$VERSION
42
+ IMAGE_ID=$(echo "$IMAGE_ID" | tr '[A-Z]' '[a-z]')
43
+ VERSION=latest
55
44
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
56
45
docker push $IMAGE_ID:$VERSION
0 commit comments