From 2f440098e2812c8238e9c478cf60863cc2007702 Mon Sep 17 00:00:00 2001 From: Marcel Lauhoff Date: Tue, 5 Sep 2023 14:43:19 +0200 Subject: [PATCH] ci: Add image build and push action Triggerd by "ci/build-s3gw-image" tag or manually Signed-off-by: Marcel Lauhoff --- .../workflows/build-image-on-pr-label.yaml | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/build-image-on-pr-label.yaml diff --git a/.github/workflows/build-image-on-pr-label.yaml b/.github/workflows/build-image-on-pr-label.yaml new file mode 100644 index 0000000000000..8e8691e1c5fea --- /dev/null +++ b/.github/workflows/build-image-on-pr-label.yaml @@ -0,0 +1,82 @@ +--- +name: Build and Push S3GW Image +on: + + pull_request: + branches: + - "s3gw" + types: [ labeled ] + + workflow_dispatch: + +env: + # Note: max 128 chars according to OCI Distribution Spec + IMAGE_TAG: pr-${{ github.workflow_sha }}-${{ github.run_id }}-${{ github.run_attempt }} + +jobs: + tests: + if: github.event.label.name == 'ci/build-s3gw-image' || github.event_name == 'workflow_dispatch' + runs-on: self-hosted + steps: + - name: Checkout s3gw + uses: actions/checkout@v3 + with: + repository: aquarist-labs/s3gw + path: s3gw + submodules: false + + - name: Checkout ceph + uses: actions/checkout@v3 + with: + path: s3gw/ceph + submodules: recursive + + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Context + run: | + docker context create builder + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + endpoint: builder + + - name: quay.io Login + uses: docker/login-action@v2 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + + - name: Build Container Image + uses: docker/build-push-action@v3 + with: + push: true + build-args: | + CMAKE_BUILD_TYPE=Release + S3GW_VERSION=${{ env.IMAGE_TAG }} + NPROC=16 + QUAY_EXPIRATION=1w + tags: | + quay.io/s3gw/s3gw:${{ env.IMAGE_TAG }} + file: s3gw/Dockerfile + context: s3gw + + - name: Add comment to image URL and image:tag + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '📦 quay.io/s3gw/s3gw:${{ env.IMAGE_TAG }} https://quay.io/repository/s3gw/s3gw?tab=tags&tag=${{ env.IMAGE_TAG }}' + })