Skip to content

Test change

Test change #13

Workflow file for this run

name: Build images for PRs
on:
# workflow_run:
# workflows: ["Trigger build images for PRs"]
# types:
# - completed
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:
fetch-data:
name: Fetch workflow payload
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v4
id: get-artifact-id
with:
result-encoding: string
script: |
const result = await octokit.request('GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts', {
owner: '${{github.repository_owner}}',
repo: '${{github.event.repository.name}}',
run_id: ${{github.event.workflow_run.id}}
})
# assumes the variables artifact is the only one in this workflow
return result.data.artifacts[0].artifact_id
- name: Get result
run: |
echo "${{steps.get-artifact-id.outputs.result}}"
curl -L -H "Authorization: token ${{github.token}}" \
-H "Accept: application/vnd.github.v3+json" \
-O variables.zip \
https://api.github.com/repos/${{github.repository}}/actions/artifacts/${{steps.get-artifact-id.outputs.result}}/zip
unzip variables.zip
# parse variables from variables.csv and set them
#
# 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