Publish Image PR check #1179
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Copyright (c) 2021-2025 Red Hat, Inc. | |
| # This program and the accompanying materials are made | |
| # available under the terms of the Eclipse Public License 2.0 | |
| # which is available at https://www.eclipse.org/legal/epl-2.0/ | |
| # | |
| # SPDX-License-Identifier: EPL-2.0 | |
| # | |
| name: Publish Image PR check | |
| on: | |
| workflow_run: | |
| workflows: ["Pull Request Check"] | |
| types: | |
| - completed | |
| jobs: | |
| publish-images: | |
| name: publish image from the pull request | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Free up disk space | |
| run: | | |
| df -h | |
| rm -rf /opt/hostedtoolcache | |
| df -h | |
| - name: Login to Quay.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: quay.io | |
| username: ${{ secrets.QUAY_PULL_REQUESTS_USERNAME }} | |
| password: ${{ secrets.QUAY_PULL_REQUESTS_PASSWORD }} | |
| - name: Download Pull Request Number artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: pull-request-number | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ github.token }} | |
| - name: Grab Pull Request number | |
| run: | | |
| pr_number=$(cat "PR_NUMBER") | |
| echo "Pull Request: ${pr_number}" | |
| if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then | |
| echo "Wrong Pull Request number" | |
| exit 1 | |
| fi | |
| echo "_PR_NUMBER=$pr_number" >> $GITHUB_ENV | |
| - name: Cleanup docker images | |
| run: | | |
| docker system prune -af | |
| - name: Download che-code docker image artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: che-* | |
| merge-multiple: true | |
| path: . | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ github.token }} | |
| - name: List downloaded files | |
| run: | | |
| ls -lahR | |
| - name: Load che-code-amd64 image | |
| run: | | |
| docker load -i che-code-amd64.tgz | |
| - name: Push che-code-amd64 docker image | |
| run: | | |
| export IMAGE=quay.io/che-incubator-pull-requests/che-code:pr-${{env._PR_NUMBER}}-amd64 | |
| docker tag che-code-amd64 ${IMAGE} | |
| docker push ${IMAGE} | |
| echo "_CHE_CODE_AMD64_IMAGE=${IMAGE}" >> $GITHUB_ENV | |
| - name: Remove che-code-amd64 and prune | |
| run: | | |
| docker image rm che-code-amd64 || true | |
| docker system prune -af | |
| - name: Load che-code-arm64 image | |
| run: | | |
| docker load -i che-code-arm64.tgz | |
| - name: Push che-code-arm64 docker image | |
| run: | | |
| export IMAGE=quay.io/che-incubator-pull-requests/che-code:pr-${{env._PR_NUMBER}}-arm64 | |
| docker tag che-code-arm64 ${IMAGE} | |
| docker push ${IMAGE} | |
| echo "_CHE_CODE_ARM64_IMAGE=${IMAGE}" >> $GITHUB_ENV | |
| - name: Remove che-code-arm64 and prune | |
| run: | | |
| docker image rm che-code-arm64 || true | |
| docker system prune -af | |
| - name: Load che-dev image | |
| run: | | |
| docker load -i che-dev.tgz | |
| - name: Push che-dev docker image | |
| run: | | |
| export IMAGE=quay.io/che-incubator-pull-requests/che-code-dev:pr-${{env._PR_NUMBER}}-dev-amd64 | |
| docker tag che-dev ${IMAGE} | |
| docker push ${IMAGE} | |
| echo "_CHE_DEV_IMAGE=${IMAGE}" >> $GITHUB_ENV | |
| - name: Remove che-dev and prune | |
| run: | | |
| docker image rm che-dev || true | |
| docker system prune -af | |
| - name: 'Comment PR' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { repo: { owner, repo } } = context; | |
| await github.rest.issues.createComment({ | |
| issue_number: process.env._PR_NUMBER, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: `Pull Request images published ✨\n\nEditor amd64: [${process.env._CHE_CODE_AMD64_IMAGE}](https://${process.env._CHE_CODE_AMD64_IMAGE})\nEditor arm64: [${process.env._CHE_CODE_ARM64_IMAGE}](https://${process.env._CHE_CODE_ARM64_IMAGE})\nDev image: [${process.env._CHE_DEV_IMAGE}](https://${process.env._CHE_DEV_IMAGE})` | |
| }) |