From 13ebb035820099fa77877ca487924d6d046cbff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirek=20D=C5=82ugosz?= Date: Mon, 3 Jul 2023 12:29:47 +0200 Subject: [PATCH] Build and upload container from GitHub Actions --- .github/workflows/build.yml | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..cdb0fde7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,46 @@ +name: Build Container Image + +on: + push: + branches: [ main ] + tags: + - '*' + pull_request: + branches: [main, 'release/*'] + +env: + STABLE_TAG: ${{ github.event_name == 'push' && github.ref_name || format('pr-{0}', github.event.pull_request.number) }} + # We had a problem with GitHub setting quay expiration label also during + # merge to main, so we just set meaningless value as a workaround. + EXPIRATION_LABEL: ${{ github.event_name == 'push' && 'quipucords.source=github' || 'quay.expires-after=3d' }} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 # fetches all commits/tags + + - name: Build qpc image + id: build-image + uses: redhat-actions/buildah-build@v2 + with: + image: quipucords/qpc + tags: ${{ env.STABLE_TAG }} ${{ env.STABLE_TAG == 'main' && 'latest' || '' }} + containerfiles: | + ./Dockerfile + labels: | + ${{ env.EXPIRATION_LABEL }} + quipucords.cli.git_sha=${{ github.sha }} + + - name: Push To quay.io + uses: redhat-actions/push-to-registry@v2 + with: + image: quipucords/qpc + tags: ${{ steps.build-image.outputs.tags }} + registry: quay.io/ + username: ${{ secrets.QUAYIO_USERNAME }} + password: ${{ secrets.QUAYIO_PASSWORD }}