Skip to content

Commit f8220df

Browse files
authored
Update ci.yaml
1 parent a7521ad commit f8220df

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

.github/workflows/ci.yaml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,41 @@ on:
55
branches:
66
- main
77

8+
#tags:
9+
# - v*
10+
811
env:
912
IMAGE_NAME: mdt-dialout-collector
1013

1114
jobs:
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
15+
ci:
2316
runs-on: ubuntu-latest
2417
permissions:
2518
packages: write
2619
contents: read
20+
2721
steps:
2822
- uses: actions/checkout@v3
2923

30-
- name: Build image again
24+
- name: Build image
3125
run: docker build docker --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
3226

33-
- name: Log in to GHCR
34-
env:
35-
GHCR_PAT: ${{ secrets.GHCR_PAT }}
36-
run: |
37-
echo "$GHCR_PAT" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
27+
- name: Log into registry
28+
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
3829

3930
- name: Push image
4031
run: |
4132
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
42-
IMAGE_ID=$(echo "$IMAGE_ID" | tr '[A-Z]' '[a-z]')
43-
VERSION=latest
33+
34+
# Change all uppercase to lowercase
35+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
36+
# Strip git ref prefix from version
37+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
38+
# Strip "v" prefix from tag name
39+
#[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
40+
# Use Docker `latest` tag convention
41+
[ "$VERSION" == "main" ] && VERSION=latest
42+
echo IMAGE_ID=$IMAGE_ID
43+
echo VERSION=$VERSION
4444
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
45-
docker push $IMAGE_ID:$VERSION
45+
docker push $IMAGE_ID:$VERSION

0 commit comments

Comments
 (0)