From 414db657966bbda2e7e8e5d037e853d95818e4b5 Mon Sep 17 00:00:00 2001 From: James Brundage <@github.com> Date: Sun, 14 Apr 2024 10:02:24 -0700 Subject: [PATCH] fix: ShowDemo Docker Publishing ( Fixes #105 ) Using secrets to publish latest from main --- .github/workflows/BuildShowDemo.yml | 10 +++++++++- Build/GitHub/Jobs/BuildShowDemo.psd1 | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/BuildShowDemo.yml b/.github/workflows/BuildShowDemo.yml index de8698c..e38c3d9 100644 --- a/.github/workflows/BuildShowDemo.yml +++ b/.github/workflows/BuildShowDemo.yml @@ -607,7 +607,15 @@ jobs: - name: PSA uses: StartAutomating/PSA@main id: PSA - - name: Log in to the Container registry + - name: Log in to the Container registry (on main) + if: ${{github.event_name != 'pull_request' && (github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'latest')}} + uses: docker/login-action@master + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GHCR_TOKEN }} + - name: Log in to the Container registry (on branch) + if: ${{github.ref_name != 'main' && github.ref_name != 'master' && github.ref_name == 'latest'}} uses: docker/login-action@master with: registry: ${{ env.REGISTRY }} diff --git a/Build/GitHub/Jobs/BuildShowDemo.psd1 b/Build/GitHub/Jobs/BuildShowDemo.psd1 index 8f0a71f..8bec79b 100644 --- a/Build/GitHub/Jobs/BuildShowDemo.psd1 +++ b/Build/GitHub/Jobs/BuildShowDemo.psd1 @@ -51,7 +51,18 @@ id = 'PSA' } @{ - 'name'='Log in to the Container registry' + 'name'='Log in to the Container registry (on main)' + if = '${{github.event_name != ''pull_request'' && (github.ref_name == ''main'' || github.ref_name == ''master'' || github.ref_name == ''latest'')}}' + 'uses'='docker/login-action@master' + 'with'=@{ + 'registry'='${{ env.REGISTRY }}' + 'username'='${{ github.actor }}' + 'password'='${{ secrets.GHCR_TOKEN }}' + } + }, + @{ + 'name'='Log in to the Container registry (on branch)' + if = '${{github.ref_name != ''main'' && github.ref_name != ''master'' && github.ref_name == ''latest''}}' 'uses'='docker/login-action@master' 'with'=@{ 'registry'='${{ env.REGISTRY }}' @@ -66,7 +77,7 @@ 'with'=@{ 'images'='${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}' } - }, + }, @{ name = 'Build and push Docker image (from main)' if = '${{github.event_name != ''pull_request'' && (github.ref_name == ''main'' || github.ref_name == ''master'' || github.ref_name == ''latest'')}}'