From db228cb5492a445567522861a5fcfcfd67488713 Mon Sep 17 00:00:00 2001 From: phala Date: Wed, 9 Aug 2023 10:04:41 +0200 Subject: [PATCH] Add automatic builds --- ...uild_image.yml => build_release_image.yml} | 3 +- .github/workflows/build_unstable_image.yml | 42 +++++++++++++++++++ .github/workflows/promote_to_latest.yml | 29 +++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) rename .github/workflows/{build_image.yml => build_release_image.yml} (96%) create mode 100644 .github/workflows/build_unstable_image.yml create mode 100644 .github/workflows/promote_to_latest.yml diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_release_image.yml similarity index 96% rename from .github/workflows/build_image.yml rename to .github/workflows/build_release_image.yml index 7a56dc1f..6811363b 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_release_image.yml @@ -8,6 +8,7 @@ on: env: IMG_REGISTRY_HOST: quay.io IMG_REGISTRY_ORG: kuadrant + IMG_NAME: testsuite jobs: build: @@ -33,7 +34,7 @@ jobs: id: build-image uses: redhat-actions/buildah-build@v2 with: - image: testsuite + image: ${{ env.IMG_NAME }} tags: ${{ env.IMG_TAGS }} layers: true platforms: linux/amd64 diff --git a/.github/workflows/build_unstable_image.yml b/.github/workflows/build_unstable_image.yml new file mode 100644 index 00000000..4a21c0aa --- /dev/null +++ b/.github/workflows/build_unstable_image.yml @@ -0,0 +1,42 @@ +name: Build and push image + +on: + push: + branches: + - main + +env: + IMG_REGISTRY_HOST: quay.io + IMG_REGISTRY_ORG: kuadrant + IMG_NAME: testsuite + IMG_TAGS: unstable + +jobs: + build: + name: Build and push image + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: Build Image + id: build-image + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.IMG_NAME }} + tags: ${{ env.IMG_TAGS }} + layers: true + platforms: linux/amd64 + containerfiles: | + ./Dockerfile + - name: Push Image + if: ${{ !env.ACT }} + id: push-to-quay + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build-image.outputs.image }} + tags: ${{ steps.build-image.outputs.tags }} + registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} + username: ${{ secrets.IMG_REGISTRY_USERNAME }} + password: ${{ secrets.IMG_REGISTRY_TOKEN }} + - name: Print Image URL + run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" diff --git a/.github/workflows/promote_to_latest.yml b/.github/workflows/promote_to_latest.yml new file mode 100644 index 00000000..98afb9f6 --- /dev/null +++ b/.github/workflows/promote_to_latest.yml @@ -0,0 +1,29 @@ +name: Promotes unstable image to latest + +on: + workflow_dispatch: + +env: + IMG_REGISTRY_HOST: quay.io + IMG_REGISTRY_ORG: kuadrant + IMG_NAME: testsuite + +jobs: + build: + name: Build and push image + runs-on: ubuntu-latest + steps: + - name: Log in to Quay.io + uses: redhat-actions/podman-login@v1 + with: + registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} + username: ${{ secrets.IMG_REGISTRY_USERNAME }} + password: ${{ secrets.IMG_REGISTRY_TOKEN }} + - name: Create repository name + run: | + echo "REPOSITORY=${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.IMG_NAME }}" >> $GITHUB_ENV + - name: Promotes to latest + run: + podman pull ${{ env.REPOSITORY }}:unstable + podman tag ${{ env.REPOSITORY }}:unstable ${{ env.REPOSITORY }}:latest + podman push ${{ env.REPOSITORY }}:latest