Skip to content

Commit

Permalink
fix: use semantic-release output for tagging docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
alixinne committed Dec 30, 2021
1 parent f6a86d0 commit 09d9d8d
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
name: build

on:
pull_request:
push:
branches:
- '*'
create:
tags:
- 'v*'
on: [pull_request, push]

jobs:
build:
Expand All @@ -27,7 +20,7 @@ jobs:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
if: "!startsWith(github.ref, 'refs/tags/v')"
id: semantic

# Setup Docker buld action
- name: Set up Docker Buildx
Expand All @@ -53,36 +46,43 @@ jobs:
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
LABEL=latest
PUSH=true
elif [[ "$GITHUB_REF" =~ "^refs/heads/v" ]]; then
LABEL="$(echo -n "$GITHUB_REF" | sed 's#refs/heads/v##')"
PUSH=true
else
LABEL="$(echo -n "$GITHUB_REF" | sed 's#refs/heads/##')"
PUSH=false
fi
echo ::set-output name=label::"$LABEL"
echo ::set-output name=push::"$PUSH"
echo ::set-output name=ghcr::"ghcr.io/${{ github.actor }}/docker-wixtoolset:$LABEL"
echo ::set-output name=ghcr::"ghcr.io/${{ github.actor }}/docker-wixtoolset"
echo ::set-output name=docker_hub::"${{ secrets.DOCKER_USERNAME }}/wixtoolset"
if [[ "${{ steps.semantic.outputs.new_release_published }}" == "true" ]]; then
echo ::set-output name=ghcr_tag::"ghcr.io/${{ github.actor }}/docker-wixtoolset:${{ steps.semantic.outputs.new_release_version }}"
echo ::set-output name=docker_hub_tag::"${{ secrets.DOCKER_USERNAME }}/wixtoolset:${{ steps.semantic.outputs.new_release_version }}"
else
echo ::set-output name=ghcr_tag::
echo ::set-output name=docker_hub_tag::
fi
id: image

- name: Build image
uses: docker/build-push-action@v2
with:
tags: ${{ steps.image.outputs.ghcr }}
tags: ${{ steps.image.outputs.ghcr }}:${{ steps.image.outputs.label }}
load: true

- name: Test image
run: |
export IMAGE_NAME="${{ steps.image.outputs.ghcr }}"
export IMAGE_NAME="${{ steps.image.outputs.ghcr }}:${{ steps.image.outputs.label }}"
./run-tests.sh
- name: Push image
uses: docker/build-push-action@v2
with:
tags: |
${{ secrets.DOCKER_USERNAME }}/wixtoolset:${{ steps.image.outputs.label }}
${{ steps.image.outputs.ghcr }}
${{ steps.image.outputs.ghcr }}:${{ steps.image.outputs.label }}
${{ steps.image.outputs.docker_hub }}:${{ steps.image.outputs.label }}
${{ steps.image.outputs.ghcr_tag }}
${{ steps.image.outputs.docker_hub_tag }}
push: ${{ steps.image.outputs.push }}

# On master, actually run semantic release
Expand Down

0 comments on commit 09d9d8d

Please sign in to comment.