Skip to content

operator-update-images #322

operator-update-images

operator-update-images #322

name: operator-update-images
on:
push:
branches:
- main
paths:
- project.yaml
workflow_dispatch:
inputs:
environment:
description: 'Select Environment'
required: true
default: 'devel'
type: choice
options:
- devel
- staging
- production
schedule:
- cron: "0 1 * * *" # At 1AM everyday
jobs:
update-csv:
runs-on: ubuntu-latest
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout the current repo
uses: actions/checkout@v4
- name: update-image-references
run: |
# Update operator's payload and stuff
make ENVIRONMENT=${{github.event.inputs.environment}} update-reference
- name: Commit new changes
run: |
BASE_BRANCH=${GITHUB_REF#refs/heads/}
SOURCE_BRANCH=actions/update/operator-update-images-${BASE_BRANCH}
git config user.name openshift-pipelines-bot
git config user.email pipelines-extcomm@redhat.com
git checkout -b ${SOURCE_BRANCH}
git add -f head .konflux
if [[ -z $(git status --porcelain --untracked-files=no) ]]; then
echo "No change, exiting"
exit 0
fi
git commit -F- <<EOF
[bot:${BASE_BRANCH}] Update generate Cluster Service Version (CSV)
EOF
git push -f origin ${SOURCE_BRANCH}
if [ "$(gh pr list --base ${BASE_BRANCH} --head ${SOURCE_BRANCH} --json url --jq 'length')" = "0" ]; then
echo "creating PR..."
gh pr create -B ${BASE_BRANCH} -H ${SOURCE_BRANCH} --label=automated --label=lgtm --label=approved --fill
else
echo "a PR already exists, editing..."
gh pr edit --title "[bot:${BASE_BRANCH}] Update generate Cluster Service Version (CSV)" --fill
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}