Skip to content

Commit

Permalink
OCP4: Fix pr image workflow
Browse files Browse the repository at this point in the history
There was a issue with existing pr image build workflow, github does not let workflow to use metal-toolbox/container-push/.github/workflows/container-push.yml@main in the steps, this PR replace metal-toolbox to build and push image directly
  • Loading branch information
Vincent056 committed Feb 5, 2024
1 parent 1dfff9b commit c287b14
Showing 1 changed file with 43 additions and 10 deletions.
53 changes: 43 additions & 10 deletions .github/workflows/k8s-content-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,54 @@ jobs:
id-token: write
packages: write
runs-on: ubuntu-latest
outputs:
image-digest: ${{ steps.container_info.outputs.image-digest }}
image-tags: ${{ steps.container_info.outputs.image-tags }}
steps:
- name: Checkout PR branch
- name: Checkout
uses: actions/checkout@v4
with:
ref: refs/pull/${{ needs.get-pr-number.outputs.pr-number }}/head
- name: Build and push container image
uses: metal-toolbox/container-push/.github/workflows/container-push.yml@main
- name: Login to ghcr.io
uses: docker/login-action@v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
name: k8scontent
tag: ${{ needs.get-pr-number.outputs.pr-number }}
latest: false
registry_org: complianceascode
dockerfile_path: ./Dockerfiles/ocp4_content
licenses: BSD
vendor: ComplianceAsCode authors
images: ghcr.io/complianceascode/k8scontent
tags: |
type=raw,value=${{ needs.get-pr-number.outputs.pr-number }}
type=sha,format=long
labels: |
org.opencontainers.image.source=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
org.opencontainers.image.title=Kubernetes content
org.opencontainers.image.version=${{ needs.get-pr-number.outputs.pr-number }}
org.opencontainers.image.licenses='Apache-2.0'
org.opencontainers.image.vendor='Compliance Operator Authors'
- name: Build container images and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfiles/ocp4_content
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
platforms: 'linux/amd64'
- name: Get container info
id: container_info
run: |
image_tags="${{ needs.get-pr-number.outputs.pr-number }}"
echo "image-digest=${{ steps.docker_build.outputs.digest }}" >> $GITHUB_OUTPUT
echo "image-tags=${{ needs.get-pr-number.outputs.pr-number }}" >> $GITHUB_OUTPUT
comment-pr:
needs:
Expand Down

0 comments on commit c287b14

Please sign in to comment.