|
| 1 | +# |
| 2 | +# Copyright (c) 2023 Red Hat, Inc. |
| 3 | +# This program and the accompanying materials are made |
| 4 | +# available under the terms of the Eclipse Public License 2.0 |
| 5 | +# which is available at https://www.eclipse.org/legal/epl-2.0/ |
| 6 | +# |
| 7 | +# SPDX-License-Identifier: EPL-2.0 |
| 8 | +# |
| 9 | +# Contributors: |
| 10 | +# Red Hat, Inc. - initial API and implementation |
| 11 | +# |
| 12 | + |
| 13 | +name: Pull Request Check |
| 14 | + |
| 15 | +# Trigger the workflow on pull request |
| 16 | +on: [pull_request] |
| 17 | + |
| 18 | +jobs: |
| 19 | + # build: |
| 20 | + # name: build |
| 21 | + # runs-on: ubuntu-22.04 |
| 22 | + # strategy: |
| 23 | + # fail-fast: false |
| 24 | + # matrix: |
| 25 | + # dist: [ 'musl', 'libc' ] |
| 26 | + # arch: ['amd64'] |
| 27 | + # steps: |
| 28 | + |
| 29 | + # - name: Checkout che-code source code |
| 30 | + # uses: actions/checkout@v3 |
| 31 | + |
| 32 | + # - name: Compile che-code |
| 33 | + # run: | |
| 34 | + # docker buildx build \ |
| 35 | + # --platform linux/${{matrix.arch}} \ |
| 36 | + # --progress=plain \ |
| 37 | + # -f build/dockerfiles/linux-${{matrix.dist}}.Dockerfile \ |
| 38 | + # -t linux-${{matrix.dist}}-${{matrix.arch}} . |
| 39 | + |
| 40 | + # - name: Upload image |
| 41 | + # uses: ishworkh/docker-image-artifact-upload@v1 |
| 42 | + # with: |
| 43 | + # image: "linux-${{matrix.dist}}-${{matrix.arch}}" |
| 44 | + |
| 45 | + # assemble: |
| 46 | + # name: assemble |
| 47 | + # runs-on: ubuntu-22.04 |
| 48 | + # needs: build |
| 49 | + # steps: |
| 50 | + |
| 51 | + # - name: Checkout che-code source code |
| 52 | + # uses: actions/checkout@v3 |
| 53 | + |
| 54 | + # - name: Cleanup docker images |
| 55 | + # run: | |
| 56 | + # docker system prune -af |
| 57 | + |
| 58 | + # - name: Download linux-libc-amd64 image |
| 59 | + # uses: ishworkh/docker-image-artifact-download@v1 |
| 60 | + # with: |
| 61 | + # image: "linux-libc-amd64" |
| 62 | + |
| 63 | + # - name: Download linux-musl-amd64 image |
| 64 | + # uses: ishworkh/docker-image-artifact-download@v1 |
| 65 | + # with: |
| 66 | + # image: "linux-musl-amd64" |
| 67 | + |
| 68 | + # - name: Login to Quay.io |
| 69 | + # uses: docker/login-action@v2 |
| 70 | + # with: |
| 71 | + # registry: quay.io |
| 72 | + # username: ${{ secrets.QUAY_PULL_REQUESTS_USERNAME }} |
| 73 | + # password: ${{ secrets.QUAY_PULL_REQUESTS_PASSWORD }} |
| 74 | + |
| 75 | + # - name: Display docker images |
| 76 | + # run: | |
| 77 | + # docker images |
| 78 | + |
| 79 | + # - name: Assemble che-code |
| 80 | + # run: | |
| 81 | + # PR_NUMBER="${{ github.event.number }}" |
| 82 | + # echo "Pull request $PR_NUMBER" |
| 83 | + |
| 84 | + # IMAGE_NAME="quay.io/che-incubator-pull-requests/che-code:pr-$PR_NUMBER-amd64" |
| 85 | + # echo "_IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV |
| 86 | + |
| 87 | + # docker buildx build \ |
| 88 | + # --platform linux/amd64 \ |
| 89 | + # --progress=plain \ |
| 90 | + # --push \ |
| 91 | + # -f build/dockerfiles/assembly.Dockerfile \ |
| 92 | + # -t ${IMAGE_NAME} . |
| 93 | + |
| 94 | + # - name: Display docker images (final) |
| 95 | + # run: | |
| 96 | + # docker images |
| 97 | + |
| 98 | + # - name: 'Comment PR' |
| 99 | + # uses: actions/github-script@v6 |
| 100 | + # with: |
| 101 | + # script: | |
| 102 | + # const { repo: { owner, repo } } = context; |
| 103 | + # await github.rest.issues.createComment({ |
| 104 | + # issue_number: context.issue.number, |
| 105 | + # owner: context.repo.owner, |
| 106 | + # repo: context.repo.repo, |
| 107 | + # body: `Pull Request Che-Code image published:\n👉 [${process.env._IMAGE_NAME}](https://${process.env._IMAGE_NAME})` |
| 108 | + # }) |
| 109 | + |
| 110 | + dev: |
| 111 | + name: dev |
| 112 | + runs-on: ubuntu-22.04 |
| 113 | + steps: |
| 114 | + |
| 115 | + - name: Checkout che-code source code |
| 116 | + uses: actions/checkout@v2 |
| 117 | + |
| 118 | + - name: Login to Quay.io |
| 119 | + uses: docker/login-action@v2 |
| 120 | + with: |
| 121 | + registry: quay.io |
| 122 | + username: ${{ secrets.QUAY_PULL_REQUESTS_USERNAME }} |
| 123 | + password: ${{ secrets.QUAY_PULL_REQUESTS_PASSWORD }} |
| 124 | + |
| 125 | + - name: Build Che-Code Docker image |
| 126 | + run: | |
| 127 | + PR_NUMBER="${{ github.event.number }}" |
| 128 | + echo "Pull request $PR_NUMBER" |
| 129 | + |
| 130 | + DEV_IMAGE_NAME="quay.io/che-incubator-pull-requests/che-code-dev:pr-$PR_NUMBER-dev-amd64" |
| 131 | + echo "Dev image $DEV_IMAGE_NAME" |
| 132 | + echo "_DEV_IMAGE_NAME=${DEV_IMAGE_NAME}" >> $GITHUB_ENV |
| 133 | + |
| 134 | + docker buildx build \ |
| 135 | + --platform linux/amd64 \ |
| 136 | + --progress=plain \ |
| 137 | + --push \ |
| 138 | + -f build/dockerfiles/dev.ssh.Dockerfile \ |
| 139 | + -t ${DEV_IMAGE_NAME} . |
| 140 | +
|
| 141 | + - name: Display docker images |
| 142 | + run: | |
| 143 | + docker images |
| 144 | +
|
| 145 | + - name: 'Comment PR' |
| 146 | + uses: actions/github-script@v6 |
| 147 | + with: |
| 148 | + script: | |
| 149 | + const { repo: { owner, repo } } = context; |
| 150 | + await github.rest.issues.createComment({ |
| 151 | + issue_number: context.issue.number, |
| 152 | + owner: context.repo.owner, |
| 153 | + repo: context.repo.repo, |
| 154 | + body: `Pull Request Dev image published:\n👉 [${process.env._DEV_IMAGE_NAME}](https://${process.env._DEV_IMAGE_NAME})` |
| 155 | + }) |
0 commit comments