Skip to content

Commit 4dca78b

Browse files
author
mbentz
committed
Migrate image to Container registry
1 parent cafac02 commit 4dca78b

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

.github/workflows/publish-image.yml

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker
1+
name: Build Image
22

33
on:
44
push:
@@ -51,44 +51,34 @@ jobs:
5151
steps:
5252
- uses: actions/checkout@v2
5353

54-
- name: Build image
55-
run: docker build . --file Dockerfile --tag $IMAGE_NAME
56-
5754
- name: Log in to GitHub Container Registry
5855
uses: docker/login-action@v1
5956
with:
6057
registry: ghcr.io
6158
username: ${{ github.repository_owner }}
6259
password: ${{ secrets.GITHUB_TOKEN }}
6360

64-
- name: Build and push image to Container Registry
65-
uses: docker/build-push-action@v2
66-
with:
67-
push: true
68-
tags: |
69-
ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
70-
ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ github.ref }}
71-
#- name: Log into registry
72-
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
73-
74-
#- name: Push image
75-
# run: |
76-
# IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
77-
61+
- name: Create Tagged Image Name
62+
run: |
63+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
64+
7865
# Change all uppercase to lowercase
79-
# IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
80-
66+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
67+
8168
# Strip git ref prefix from version
82-
# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
83-
69+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
70+
8471
# Strip "v" prefix from tag name
85-
# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
86-
72+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
73+
8774
# Use Docker `latest` tag convention
88-
# [ "$VERSION" == "master" ] && VERSION=latest
75+
[ "$VERSION" == "master" ] && VERSION=latest
8976
90-
# echo IMAGE_ID=$IMAGE_ID
91-
# echo VERSION=$VERSION
77+
echo "TAGGED_IMAGE_NAME=$IMAGE_ID:$VERSION" >> $GITHUB_ENV
9278
93-
# docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
94-
# docker push $IMAGE_ID:$VERSION
79+
- name: Build and push image to Container Registry
80+
uses: docker/build-push-action@v2
81+
with:
82+
push: true
83+
tags: |
84+
${{ env.TAGGED_IMAGE_NAME }}

0 commit comments

Comments
 (0)