Skip to content

Commit

Permalink
.github/workflow: add an index-render-template-next…
Browse files Browse the repository at this point in the history
… same as main but for the next branch

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester committed Dec 11, 2024
1 parent 5e99938 commit 0c726c9
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/index-render-template-next.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: index-render-template-next

on:
workflow_dispatch: {}
push:
branch:
- "next"
branches-ignore:
- "konflux/**/next**"
paths:
- .konflux/olm-catalog/index/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-matrix:
runs-on: ubuntu-latest
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
ref: next
- id: set-matrix
run: |
pushd .konflux/olm-catalog/index
VERSIONS=$(ls -d v* | jq -R -s -c 'split("\n")[:-1]')
popd
echo "Versions: ${VERSIONS}"
echo "versions=${VERSIONS}" >> $GITHUB_OUTPUT
outputs:
versions: ${{ steps.set-matrix.outputs.versions }}
generate-catalog:
needs: build-matrix
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.build-matrix.outputs.versions) }}
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
ref: next
- name: Generate ${{matrix.version}} catalog
run: |
echo ${{matrix.version}}
curl -sSfLo /usr/local/bin/opm "https://github.com/operator-framework/operator-registry/releases/download/v1.47.0/linux-amd64-opm"
chmod +x /usr/local/bin/opm
BUNDLE_IMAGE=$(jq -r '.entries[] | select(.schema == "olm.bundle") | .image' .konflux/olm-catalog/index/${{matrix.version}}/catalog-template.json)
BUNDLE_VERSION=$(opm render --skip-tls-verify -o json ${BUNDLE_IMAGE} | jq -r '.name' | awk -F 'v' '{ print $2 }')
# Update catalog-template
sed -i "s%5.0.5-[0-9]\+%${BUNDLE_VERSION}%g" .konflux/olm-catalog/index/${{matrix.version}}/catalog-template.json
opm alpha render-template basic .konflux/olm-catalog/index/${{matrix.version}}/catalog-template.json > .konflux/olm-catalog/index/${{matrix.version}}/catalog/openshift-pipelines-operator-rh/catalog.json
- name: Commit new changes
run: |
git config user.name openshift-pipelines-bot
git config user.email [email protected]
git checkout -b actions/index-next/${{matrix.version}}
git add .konflux/olm-catalog/index/${{matrix.version}}/catalog
if [[ -z $(git status --porcelain --untracked-files=no) ]]; then
echo "No change, exiting"
exit 0
fi
git commit -F- <<EOF
[bot:next] Update ${{matrix.version}} generate catalog
EOF
git push -f origin actions/index-next/${{matrix.version}}
if [ "$(gh pr list --base next --head actions/index-next/${{matrix.version}} --json url --jq 'length')" = "0" ]; then
echo "creating PR..."
gh pr create -B next -H actions/index-next/${{matrix.version}} --label=automated --fill
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 0c726c9

Please sign in to comment.