Skip to content

Commit

Permalink
Merge pull request #139 from stakater/fix-IMAGE_REPOSITORY
Browse files Browse the repository at this point in the history
  • Loading branch information
rasheedamir authored Dec 13, 2024
2 parents f48dacb + 50154d5 commit 4acc0ce
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/pull_request_container_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,21 @@ jobs:
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
ref: ${{github.event.pull_request.head.sha}}

- name: Generate Tag
- name: Generate image repository path
id: image_repo_path
run: |
echo "IMAGE_REPOSITORY=$(echo ${{ secrets.CONTAINER_REGISTRY_URL }}/${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Generate image tag
id: generate_tag
run: |
sha=${{ github.event.pull_request.head.sha }}
tag="SNAPSHOT-PR-${{ github.event.pull_request.number }}-${sha:0:8}"
echo "GIT_TAG=$(echo ${tag})" >> $GITHUB_OUTPUT
- name: Set Output
- name: Generate image path
id: set_output
run: echo "IMAGE_PATH=${{ env.IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}" >> $GITHUB_OUTPUT
run: echo "IMAGE_PATH=${{ steps.image_repo_path.outputs.IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}" >> $GITHUB_OUTPUT

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -80,10 +85,6 @@ jobs:
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}

- name: Generate image repository path
run: |
echo IMAGE_REPOSITORY=$(echo ${{ secrets.CONTAINER_REGISTRY_URL }}/${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v6
with:
Expand All @@ -95,7 +96,7 @@ jobs:
build-args: BUILD_PARAMETERS=${{ inputs.BUILD_PARAMETERS }}
cache-to: type=inline
tags: |
${{ env.IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}
${{ steps.set_output.outputs.IMAGE_PATH }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.revision=${{ github.sha }}
Expand All @@ -106,7 +107,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message-success: '@${{ github.actor }} Image is available for testing. `docker pull ${{ env.IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}`'
message-success: '@${{ github.actor }} Image is available for testing. `docker pull ${{ steps.set_output.outputs.IMAGE_PATH }}`'
message-failure: '@${{ github.actor }} Yikes! You better fix it before anyone else finds out! [Build](https://github.com/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha }}/checks) has Failed!'
allow-repeats: true

Expand Down

0 comments on commit 4acc0ce

Please sign in to comment.