Skip to content

Commit

Permalink
Migrate image to Container registry
Browse files Browse the repository at this point in the history
  • Loading branch information
mbentz committed Jun 29, 2021
1 parent cafac02 commit 4dca78b
Showing 1 changed file with 19 additions and 29 deletions.
48 changes: 19 additions & 29 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker
name: Build Image

on:
push:
Expand Down Expand Up @@ -51,44 +51,34 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image to Container Registry
uses: docker/build-push-action@v2
with:
push: true
tags: |
ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:${{ github.ref }}
#- name: Log into registry
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin

#- name: Push image
# run: |
# IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME

- name: Create Tagged Image Name
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
# IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')

IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')

[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
# [ "$VERSION" == "master" ] && VERSION=latest
[ "$VERSION" == "master" ] && VERSION=latest
# echo IMAGE_ID=$IMAGE_ID
# echo VERSION=$VERSION
echo "TAGGED_IMAGE_NAME=$IMAGE_ID:$VERSION" >> $GITHUB_ENV
# docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
# docker push $IMAGE_ID:$VERSION
- name: Build and push image to Container Registry
uses: docker/build-push-action@v2
with:
push: true
tags: |
${{ env.TAGGED_IMAGE_NAME }}

0 comments on commit 4dca78b

Please sign in to comment.