Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
fix image builds in CI
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Sadler <ansadler@redhat.com>
  • Loading branch information
sadlerap committed Apr 8, 2024
1 parent bdc6790 commit febfc59
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build container images
on: # yamllint disable-line rule:truthy
push:
branches: [main]
pull_request:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]

env:
Expand All @@ -24,7 +24,7 @@ jobs:
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
Expand All @@ -42,24 +42,23 @@ jobs:
go-version: ${{ env.GO_VERSION }}
cache: false

- name: Determine image tag
- name: Build image
id: tag
run: |
if [[ "${GITHUB_EVENT_NAME}" -eq "pull_request_target" ]]; then
echo "tag=${{ matrix.image_base }}:pr-${{ github.event.pull_request.number }}-${GITHUB_SHA:0:8}" >> ${GITHUB_OUTPUT}
export IMG="${{ matrix.image_base }}:pr-${{ github.event.pull_request.number }}-${GITHUB_SHA:0:8}"
else
echo "tag=${{ matrix.image_base }}:${GITHUB_SHA:0:8}" >> ${GITHUB_OUTPUT}
export IMG="${{ matrix.image_base }}:${GITHUB_SHA:0:8}"
fi
echo "tag=${IMG}" >> ${GITHUB_OUTPUT}
make -C "${{ matrix.directory }}" docker-build
- name: Build image
- name: Tag image with :latest
if: ${{ github.event_name == 'push' }}
env:
LATEST: ${{ matrix.image_base }}:latest
IMG: ${{ steps.tag.outputs.tag }}
run: |
make -C "${{ matrix.directory }}" docker-build
if [[ "${GITHUB_EVENT_NAME}" -eq "push" ]]; then
docker tag "${IMG}" "${LATEST}"
fi
run: docker tag "${IMG}" "${LATEST}"

- name: Login to Quay
uses: docker/login-action@v3
Expand All @@ -69,5 +68,4 @@ jobs:
password: ${{ secrets.QUAY_TOKEN }}

- name: Push images
run: |
docker push -a ${{ matrix.image_base }}
run: docker push -a ${{ matrix.image_base }}

0 comments on commit febfc59

Please sign in to comment.