Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
chore: update github action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rmoesbergen committed Oct 6, 2023
1 parent 672fc4e commit fb8b957
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch: {}

env:
IMAGE_NAME: fotoalbum
IMAGE_NAME: docker.pkg.github.com/djoamersfoort/djo-fotoalbum/fotoalbum:main

jobs:
# Push image to GitHub Packages.
Expand All @@ -20,27 +20,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Docker Login
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
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//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
docker push $IMAGE_NAME

0 comments on commit fb8b957

Please sign in to comment.