Skip to content

Test change

Test change #10

Workflow file for this run

name: Build images for PRs
on:
pull_request:
types:
- opened
- reopened
- closed
- synchronize
permissions:
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
IMAGE_REPO_DSPO: data-science-pipelines-operator
SOURCE_BRANCH: ${{ github.event.pull_request.head.sha }}
QUAY_ORG: opendatahub
QUAY_ID: ${{ secrets.QUAY_ID }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
TARGET_IMAGE_TAG: pr-${{ github.event.pull_request.number }}
GH_USER_EMAIL: 140449482+dsp-developers@users.noreply.github.com
GH_USER_NAME: dsp-developers
jobs:
build-pr-image:
if: github.event.pull_request.state == 'open'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Image
uses: ./.github/actions/build
with:
OVERWRITE: true
IMAGE_REPO: ${{ env.IMAGE_REPO_DSPO }}
DOCKERFILE: Dockerfile
GH_REPO: ${{ github.repository }}
- name: Send comment
shell: bash
env:
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
IMG: quay.io/${{ env.QUAY_ORG }}/${{ env.IMAGE_REPO_DSPO }}:${{ env.TARGET_IMAGE_TAG }}
run: |
git config user.email "${{ env.GH_USER_EMAIL }}"
git config user.name "${{ env.GH_USER_NAME }}"
action=${{ github.event.action }}
if [[ "$action" == "synchronize" ]]; then
echo "Change to PR detected. A new PR build was completed." >> /tmp/body-file.txt
fi
if [[ "$action" == "reopened" ]]; then
echo "PR was re-opened." >> /tmp/body-file.txt
fi
cat <<"EOF" >> /tmp/body-file.txt
A new image has been built to help with testing out this PR: `${{ env.IMG }}`
EOF
if [[ "$action" == "opened" || "$action" == "reopened" ]]; then
cat <<"EOF" >> /tmp/body-file.txt
An OCP cluster where you are logged in as cluster admin is required.
To use this image run the following:
```bash
cd $(mktemp -d)
git clone git@github.com:opendatahub-io/data-science-pipelines-operator.git
cd data-science-pipelines-operator/
git fetch origin pull/${{ github.event.pull_request.number }}/head
git checkout -b pullrequest ${{ env.SOURCE_BRANCH }}
make deploy IMG="${{ env.IMG }}"
```
More instructions [here](https://github.com/opendatahub-io/data-science-pipelines-operator#deploy-dsp-instance) on how to deploy and test a Data Science Pipelines Application.
EOF
fi
gh pr comment ${{ github.event.pull_request.number }} --body-file /tmp/body-file.txt
clean-pr-images:
if: github.event.pull_request.state == 'closed'
runs-on: ubuntu-latest
steps:
- name: Delete PR image
shell: bash
run: |
tag=$(curl --request GET 'https://quay.io/api/v1/repository/${{ env.QUAY_ORG }}/${{ env.IMAGE_REPO_DSPO }}/tag/?specificTag=${{ env.TARGET_IMAGE_TAG }}')
exists=$(echo ${tag} | yq .tags - | yq any)
IMAGE=quay.io/${{ env.QUAY_ORG }}/${{ env.IMAGE_REPO_DSPO }}:${{ env.TARGET_IMAGE_TAG }}
if [[ "$exists" == "true" ]]; then
echo "PR Closed deleting image...${{ env.IMAGE }}."
skopeo delete --creds ${{ env.QUAY_ID }}:${{ env.QUAY_TOKEN }} docker://${IMAGE}
else
echo "Deletion of image ${IMAGE} skipped because image already does not exist."
fi