|
| 1 | +name: Build and push PR image to quay.io |
| 2 | +on: |
| 3 | + pull_request_target: |
| 4 | + types: [labeled] |
| 5 | + |
| 6 | +env: |
| 7 | + REGISTRY_USER: netobserv+github_ci |
| 8 | + REGISTRY: quay.io/netobserv |
| 9 | + IMAGE: netobserv-agent |
| 10 | + IMAGE_ORG: netobserv |
| 11 | + |
| 12 | +jobs: |
| 13 | + push-pr-image: |
| 14 | + if: ${{ github.event.label.name == 'ok-to-test' }} |
| 15 | + name: push PR image |
| 16 | + runs-on: ubuntu-20.04 |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + go: ['1.17'] |
| 20 | + steps: |
| 21 | + - name: install make |
| 22 | + run: sudo apt-get install make |
| 23 | + - name: set up go 1.x |
| 24 | + uses: actions/setup-go@v2 |
| 25 | + with: |
| 26 | + go-version: ${{ matrix.go }} |
| 27 | + - name: checkout |
| 28 | + uses: actions/checkout@v2 |
| 29 | + with: |
| 30 | + ref: "refs/pull/${{ github.event.number }}/merge" |
| 31 | + - name: build images |
| 32 | + run: SW_VERSION=temp make ci-images-build |
| 33 | + - name: podman login to quay.io |
| 34 | + uses: redhat-actions/podman-login@v1 |
| 35 | + with: |
| 36 | + username: ${{ env.REGISTRY_USER }} |
| 37 | + password: ${{ secrets.QUAY_SECRET }} |
| 38 | + registry: quay.io |
| 39 | + - name: get short sha |
| 40 | + id: shortsha |
| 41 | + run: echo "::set-output name=short_sha::$(git rev-parse --short HEAD)" |
| 42 | + - name: push to quay.io |
| 43 | + id: push-to-quay |
| 44 | + uses: redhat-actions/push-to-registry@v2 |
| 45 | + with: |
| 46 | + image: ${{ env.IMAGE }} |
| 47 | + tags: ${{ steps.shortsha.outputs.short_sha }} |
| 48 | + registry: ${{ env.REGISTRY }} |
| 49 | + - uses: actions/github-script@v5 |
| 50 | + with: |
| 51 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 52 | + script: | |
| 53 | + github.rest.issues.createComment({ |
| 54 | + issue_number: context.issue.number, |
| 55 | + owner: context.repo.owner, |
| 56 | + repo: context.repo.repo, |
| 57 | + body: 'New image: ${{ steps.push-to-quay.outputs.registry-paths }}. It will expire after two weeks.' |
| 58 | + }) |
0 commit comments