QoL: add early checks for being logged in to quay.io #540
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
| name: publish-sandbox-ui-for-ui-e2e-tests | |
| on: | |
| issue_comment: | |
| types: [created] | |
| pull_request_target: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| publish-sandbox-ui-for-ui-e2e-tests: | |
| name: Build & push Developer Sandbox UI image for UI e2e tests | |
| runs-on: ubuntu-24.04 | |
| if: >- | |
| ${{ github.event_name == 'pull_request_target' || | |
| (github.event_name == 'issue_comment' && | |
| (contains(github.event.comment.body, '/retest') || | |
| contains(github.event.comment.body, '/test all') || | |
| contains(github.event.comment.body, '/test e2e'))) }} | |
| steps: | |
| # Checkout from PR event | |
| - name: Checkout code from PR event | |
| uses: actions/checkout@v5 | |
| if: ${{ github.event_name == 'pull_request_target' }} | |
| with: | |
| ref: ${{github.event.pull_request.head.ref}} | |
| repository: ${{github.event.pull_request.head.repo.full_name}} | |
| fetch-depth: 0 | |
| # If the workflow was triggered based on comment, then we need to get the information about the PR | |
| - name: Send Github API Request to get PR data | |
| id: request | |
| uses: octokit/request-action@v2.4.0 | |
| if: ${{ github.event_name == 'issue_comment' }} | |
| with: | |
| route: ${{ github.event.issue.pull_request.url }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Checkout the code based on the data retrieved from the previous step | |
| # Is executed only for comment events | |
| - name: Checkout code from PR | |
| uses: actions/checkout@v5 | |
| if: ${{ github.event_name == 'issue_comment' }} | |
| with: | |
| repository: ${{ fromJson(steps.request.outputs.data).head.repo.full_name }} | |
| ref: ${{ fromJson(steps.request.outputs.data).head.ref }} | |
| fetch-depth: 0 | |
| - name: Install Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.x" | |
| - name: Prepare tools | |
| uses: codeready-toolchain/toolchain-cicd/prepare-tools-action@master | |
| - name: Login to quay | |
| run: | | |
| set -e | |
| export XDG_RUNTIME_DIR=/run/user/${UID} | |
| mkdir -p ${XDG_RUNTIME_DIR}/containers || true | |
| echo "{ | |
| \"auths\": { | |
| \"quay.io\": { | |
| \"auth\": \"${{ secrets.TEST_QUAY_TOKEN }}\" | |
| } | |
| } | |
| }"> ${XDG_RUNTIME_DIR}/containers/auth.json | |
| podman login --get-login quay.io | |
| # Publish Developer Sandbox UI for PR events | |
| - name: Publish current Developer Sandbox UI (PR event) | |
| if: ${{ github.event_name == 'pull_request_target' }} | |
| run: | | |
| make push-sandbox-plugin QUAY_NAMESPACE=codeready-toolchain-test IMAGE_BUILDER=podman PULL_PULL_SHA=${{ github.event.pull_request.head.sha }} PULL_NUMBER=${{ github.event.pull_request.number }} AUTHOR=${{ github.event.pull_request.head.user.login }} BRANCH_NAME=${{ github.event.pull_request.head.ref }} | |
| # Publish Developer Sandbox UI for comment events | |
| - name: Publish current Developer Sandbox UI (comment event) | |
| if: ${{ github.event_name == 'issue_comment' }} | |
| run: | | |
| make push-sandbox-plugin QUAY_NAMESPACE=codeready-toolchain-test IMAGE_BUILDER=podman PULL_PULL_SHA=${{ fromJson(steps.request.outputs.data).head.sha }} PULL_NUMBER=${{ fromJson(steps.request.outputs.data).number }} AUTHOR=${{ fromJson(steps.request.outputs.data).head.user.login }} BRANCH_NAME=${{ fromJson(steps.request.outputs.data).head.ref }} |