Skip to content

Commit

Permalink
[container] Add possibility to properly generate again a commit or a …
Browse files Browse the repository at this point in the history
…version
  • Loading branch information
hacketiwack committed Feb 23, 2024
1 parent aa08c7b commit 63dbc0f
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
preparation:
runs-on: ubuntu-latest
outputs:
commit: ${{ steps.next-stages.outputs.commit }}
version: ${{ steps.next-stages.outputs.version }}
commit: ${{ steps.variables.outputs.commit }}
version: ${{ steps.variables.outputs.version }}
steps:
- name: Determine run of next stages
id: next-stages
- name: Determine variables
id: variables
run: |
registry=https://hub.docker.com/v2/namespaces/$NAMESPACE/repositories/$NAME/tags
git clone -q -b $REPOSITORY_BRANCH $REPOSITORY_URL source
Expand All @@ -43,9 +43,18 @@ jobs:
staging:
needs: preparation
outputs:
tags: ${{ steps.variables.outputs.tags }}
runs-on: ubuntu-latest
if: needs.preparation.outputs.commit
steps:
- name: Determine variables
id: variables
run: |
prefix=${{ env.NAMESPACE }}/${{ env.NAME }}:
tags=${prefix}${{ needs.preparation.outputs.commit }}
[[ -z ${{ github.event.inputs.commit }} ]] && tags+=",${prefix}staging"
echo "tags=${tags}" >> $GITHUB_OUTPUT
- name: Check out the repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
Expand All @@ -65,9 +74,8 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.NAMESPACE }}/${{ env.NAME }}:staging
${{ env.NAMESPACE }}/${{ env.NAME }}:${{ needs.preparation.outputs.commit }}
tags: ${{ steps.variables.outputs.tags }}


production:
needs: preparation
Expand All @@ -80,8 +88,8 @@ jobs:
id: variables
run: |
prefix=${{ env.NAMESPACE }}/${{ env.NAME }}:
rerun=${{ github.event.inputs.version }}
tags=$(printf "${prefix}%s" ${rerun:+"latest,"})${prefix}${{ needs.preparation.outputs.version }}
tags=${prefix}${{ needs.preparation.outputs.version }}
[[ -z ${{ github.event.inputs.version }} ]] && tags+=",${prefix}latest"
echo "tags=${tags}" >> $GITHUB_OUTPUT
- name: Check out the repository
uses: actions/checkout@v3
Expand All @@ -102,5 +110,4 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: |
${{ steps.variables.outputs.tags }}
tags: ${{ steps.variables.outputs.tags }}

0 comments on commit 63dbc0f

Please sign in to comment.