From e771ff8169f5254ba9732ae0fba633e3fdee9f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Mon, 22 Jan 2024 12:11:41 +0100 Subject: [PATCH] github/workflows/arch: Unified workflow, use buildah & podman MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use a unified workflow for both PR & Push jobs - Build using buildah & push with podman Signed-off-by: Timothée Ravier --- .github/workflows/arch-images-pr.yaml | 31 ------------- .github/workflows/arch-images.yaml | 63 ++++++++++++++++++--------- 2 files changed, 42 insertions(+), 52 deletions(-) delete mode 100644 .github/workflows/arch-images-pr.yaml diff --git a/.github/workflows/arch-images-pr.yaml b/.github/workflows/arch-images-pr.yaml deleted file mode 100644 index 5f0c7cfaf..000000000 --- a/.github/workflows/arch-images-pr.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: Build the arch-toolbox image for PRs - -on: - pull_request: - branches: - - main - paths: - - images/arch/** - - .github/workflows/arch-images-pr.yaml - -jobs: - build-and-push-images: - name: Build the arch-toolbox image for PRs - - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Build the arch-toolbox image - uses: docker/build-push-action@v3 - with: - context: images/arch - file: images/arch/Containerfile - platforms: linux/amd64 - push: false - no-cache: true - tags: quay.io/toolbx/arch-toolbox:latest diff --git a/.github/workflows/arch-images.yaml b/.github/workflows/arch-images.yaml index d2e855501..8c6fdfe67 100644 --- a/.github/workflows/arch-images.yaml +++ b/.github/workflows/arch-images.yaml @@ -1,6 +1,14 @@ -name: Build and push the arch-toolbox image +name: "Arch Linux: Build and push arch-toolbox image" + +permissions: read-all on: + pull_request: + branches: + - main + paths: + - images/arch/** + - .github/workflows/arch-images.yaml push: branches: - main @@ -10,34 +18,47 @@ on: schedule: - cron: '0 0 * * MON' -# Prevent multiple workflow runs from racing -concurrency: ${{ github.workflow }} +env: + distro: 'arch' + platforms: 'linux/amd64' + registry: 'quay.io/toolbx' + username: 'toolbx+github' + +# Prevent multiple workflow runs from racing to ensure that pushes are made +# sequentialy for the main branch. Also cancel in progress workflow runs for +# pull requests only. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - build-and-push-images: + build-push-images: name: Build and push the arch-toolbox image runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: actions/checkout@v4 - - name: Log in to Quay.io - uses: docker/login-action@v2 + - name: Build container image (latest tag) + uses: redhat-actions/buildah-build@v2 + if: env.latest_release == matrix.release with: - registry: quay.io - username: 'toolbx+github' - password: ${{ secrets.QUAY_ROBOT_TOKEN }} + platforms: ${{ env.platforms }} + context: images/${{ env.distro }} + image: ${{ env.distro }}-toolbox + tags: latest + containerfiles: images/${{ env.distro }}/Containerfile + layers: false + oci: true - - name: Build and push the arch-toolbox image - uses: docker/build-push-action@v3 + - name: Push to Container Registry (latest tag) + uses: redhat-actions/push-to-registry@v2 + id: push-latest + if: (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/main' with: - context: images/arch - file: images/arch/Containerfile - platforms: linux/amd64 - push: true - no-cache: true - tags: quay.io/toolbx/arch-toolbox:latest + username: ${{ env.username }} + password: ${{ secrets.QUAY_ROBOT_TOKEN }} + image: ${{ env.distro }}-toolbox + registry: ${{ env.registry }} + tags: latest