Skip to content

Commit

Permalink
chore: rework docker tag generation. any git tags should update `late…
Browse files Browse the repository at this point in the history
…st` image
  • Loading branch information
Julusian committed Oct 11, 2023
1 parent ff43f32 commit 3011628
Showing 1 changed file with 20 additions and 36 deletions.
56 changes: 20 additions & 36 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,62 +339,46 @@ jobs:
IMAGE_NAME: companion

steps:
- uses: actions/checkout@v3
if: ${{ needs.linux64.outputs.do-docker }}

- name: Determine target image name
- name: Docker meta
if: ${{ needs.linux64.outputs.do-docker }}
id: image-name
run: |
BUILD_VERSION=${{ needs.linux64.outputs.version }}
IMAGE_ID=ghcr.io/${{ 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
IMAGES=
IMAGES="$IMAGE_ID:$VERSION,$IMAGES"
# IMAGES="$IMAGE_ID:$BUILD_VERSION,$IMAGES" TODO - this would be nice to have, but the version needs making docker-tag safe first
# debug output
echo images $IMAGES
echo "images=$IMAGES" >> $GITHUB_OUTPUT
echo "build_version=$BUILD_VERSION" >> $GITHUB_OUTPUT
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ needs.linux64.outputs.version }}
type=ref,event=tag
type=ref,event=branch
- name: Set up QEMU
if: ${{ steps.image-name.outputs.images }}
if: ${{ steps.meta.outputs.tags }}
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
if: ${{ steps.image-name.outputs.images }}
if: ${{ steps.meta.outputs.tags }}
uses: docker/setup-buildx-action@v2

- name: Login to registry
if: ${{ steps.image-name.outputs.images }}
if: ${{ steps.meta.outputs.tags }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v3
if: ${{ steps.meta.outputs.tags }}

- name: Build and push
uses: docker/build-push-action@v3
if: ${{ steps.image-name.outputs.images }}
if: ${{ steps.meta.outputs.tags }}
with:
context: .
file: Dockerfile.prebuild
platforms: linux/amd64,linux/arm64/v8
push: true
tags: ${{ steps.image-name.outputs.images }}
labels: ${{ steps.meta.outputs.labels }}
tags: '${{ steps.meta.outputs.tags }}'
build-args: |
build_name=${{ steps.image-name.outputs.build_version }}
build_name=${{ needs.linux64.outputs.version }}

0 comments on commit 3011628

Please sign in to comment.