Skip to content

Publish Image PR check #295

Publish Image PR check

Publish Image PR check #295

#
# Copyright (c) 2021 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: 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 Docker images
run: |
docker load -i che-code.tgz
docker load -i che-dev.tgz
- 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: Push che-code docker image
run: |
export IMAGE=quay.io/che-incubator-pull-requests/che-code:pr-${{env._PR_NUMBER}}-amd64
docker tag che-code ${IMAGE}
docker push ${IMAGE}
echo "_CHE_CODE_IMAGE=${IMAGE}" >> $GITHUB_ENV
- 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: '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: [${process.env._CHE_CODE_IMAGE}](https://${process.env._CHE_CODE_IMAGE})\nDev image: [${process.env._CHE_DEV_IMAGE}](https://${process.env._CHE_DEV_IMAGE})`
})