From e2680d5a4522e2edb7960db88e25e031f6ca8f3d Mon Sep 17 00:00:00 2001 From: Jason Madigan Date: Thu, 26 Sep 2024 14:59:21 +0100 Subject: [PATCH] GH action for builds Signed-off-by: Jason Madigan --- .github/workflows/build.yaml | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..e6ec65c --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,50 @@ +name: Build and Push Image + +on: + push: + branches: + - main # This ensures the action only runs on pushes to the main branch + +env: + REGISTRY_USER: ${{ secrets.QUAY_USER }} + IMAGE_REGISTRY: quay.io + REGISTRY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + +jobs: + build: + name: Build and push image + runs-on: ubuntu-22.04 + + steps: + # Step 1: Log in to Quay.io + - name: Log in to Quay.io + uses: redhat-actions/podman-login@v1 + with: + username: ${{ env.REGISTRY_USER }} + password: ${{ env.REGISTRY_PASSWORD }} + registry: ${{ env.IMAGE_REGISTRY }} + + # Step 2: Check out the repository + - uses: actions/checkout@v4 + + # Step 3: Build the image using Buildah + - name: Build Image + id: build-image + uses: redhat-actions/buildah-build@v2 + with: + image: quay.io/kuadrant/console-plugin # Fully qualify the image name for Quay.io + tags: latest,${{ github.sha }} # Tag as "latest" and with the current commit SHA + containerfiles: | + ./Dockerfile + + # Step 4: Push the image to Quay.io + - name: Push To Quay.io + id: push-to-quay + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build-image.outputs.image }} + tags: ${{ steps.build-image.outputs.tags }} + + # Step 5: Print the image URL + - name: Print image URL + run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"