diff --git a/.github/workflows/reusable_docker_pipeline.yml b/.github/workflows/reusable_docker_pipeline.yml index e08c1a1..b5b351c 100644 --- a/.github/workflows/reusable_docker_pipeline.yml +++ b/.github/workflows/reusable_docker_pipeline.yml @@ -33,39 +33,39 @@ jobs: build-secrets: ${{ steps.set-build-secrets.outputs.SECRETS }} build-tags: ${{ steps.set-build-tags.outputs.TAGS }} steps: - - name: Determine image name - id: set_image_name - run: | - if [ -n "${{ inputs.repoName }}" ]; then - echo "IMAGE_NAME=${{ inputs.repoName }}" >> $GITHUB_ENV - else - echo "IMAGE_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)" >> $GITHUB_ENV - fi - - # This block is used to not hard-coded the secrets in Build Docker image - # Secrets are only added when necessary - - name: Generate and mask build secrets - id: set-build-secrets - run: | - SECRETS="" - if [ -n "${{ inputs.go-private-repos-authentication }}" ]; then - SECRETS+='"GO_PRIVATE_TOKEN=${{ secrets.GO_PRIVATE_TOKEN }}"\n' - fi - echo "::add-mask::$SECRETS" - echo "SECRETS<> $GITHUB_OUTPUT - echo -e "$SECRETS" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - shell: bash - - - name: Prepare tags - id: set-build-tags + - name: Determine image name + id: set_image_name run: | - BASE_TAG="${{ env.IMAGE_NAME }}:${{ github.sha }}" - TAGS="$BASE_TAG" - if [[ $GITHUB_REF == refs/tags/* ]]; then - TAGS="$TAGS ${{ env.IMAGE_NAME }}:${{ github.ref_name }}" + if [ -n "${{ inputs.repoName }}" ]; then + echo "IMAGE_NAME=${{ inputs.repoName }}" >> $GITHUB_ENV + else + echo "IMAGE_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)" >> $GITHUB_ENV fi - echo "TAGS=$TAGS" >> $GITHUB_OUTPUT + + # This block is used to not hard-coded the secrets in Build Docker image + # Secrets are only added when necessary + - name: Generate and mask build secrets + id: set-build-secrets + run: | + SECRETS="" + if [ -n "${{ inputs.go-private-repos-authentication }}" ]; then + SECRETS+='"GO_PRIVATE_TOKEN=${{ secrets.GO_PRIVATE_TOKEN }}"\n' + fi + echo "::add-mask::$SECRETS" + echo "SECRETS<> $GITHUB_OUTPUT + echo -e "$SECRETS" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + shell: bash + + - name: Prepare tags + id: set-build-tags + run: | + BASE_TAG="${{ env.IMAGE_NAME }}:${{ github.sha }}" + TAGS="$BASE_TAG" + if [[ $GITHUB_REF == refs/tags/* ]]; then + TAGS="$TAGS ${{ env.IMAGE_NAME }}:${{ github.ref_name }}" + fi + echo "TAGS=$TAGS" >> $GITHUB_OUTPUT docker_build: runs-on: ubuntu-22.04