Skip to content

generate-catalogs

generate-catalogs #680

---
name: generate-catalogs
on:
schedule:
- cron: "0 */6 * * *" # every 6 hours
workflow_dispatch:
# allow manual triggering
jobs:
catalog-matrix:
runs-on: ubuntu-latest
if: github.repository_owner == 'shortbrain' # do not run this elsewhere
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: openshift-pipelines/catalog-cd/actions/setup-catalog-cd@main
- id: set-matrix
name: Generate catalog matrix
run: |
set -Eeu
# Run catalog-cd
echo "matrix=$(catalog-cd catalog externals --config ./externals.yaml)" >> "$GITHUB_OUTPUT"
cat "$GITHUB_OUTPUT"
generate-catalog:
needs: catalog-matrix
runs-on: ubuntu-latest
if: github.repository_owner == 'shortbrain' # do not run this elsewhere
strategy:
matrix: ${{fromJSON(needs.catalog-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: openshift-pipelines/catalog-cd/actions/setup-catalog-cd@main
- name: ${{ matrix.type }} catalog for ${{ matrix.name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p tasks pipelines
catalog-cd catalog generate-from \
--name ${{ matrix.name }} \
--url ${{ matrix.url }} \
--type ${{ matrix.type }} \
--ignore-versions "${{ matrix.ignoreVersions }}" \
.
- name: Add ${{ matrix.type }} from ${{ matrix.name }} to publish branch
run: |
# Clean main from here before the status
git config user.name github-actions
git config user.email [email protected]
CHANGES=$(git status -s)
if [[ -n "${CHANGES}" ]]; then
git status
git add tasks pipelines
git commit -m "${{ matrix.name }}: Auto-update tekton ${{ matrix.type }} resources\n\nURL: ${{ matrix.url }}\\nIgnoredVersions: ${{ matrix.ignoreVersions }}"
git pull --rebase --autostash
else
echo "No changes for the catalog"
fi
- name: Create PR
id: create-pr
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5
with:
base: main
branch: update-${{ matrix.name }}-${{ matrix.type }}
delete-branch: true
add-paths: README.md # This is here just to force it to not commit anything
title: "${{ matrix.name }}: Auto-update tekton ${{ matrix.type }} resources"
assignees: tekton-ecosystem-team
labels: approved, lgtm, ok-to-test # Automatically approved :)
# committer: ${{ env.GIT_COMMITTER_NAME }} ${{ env.GIT_COMMITTER_EMAIL }}
# author: ${{ env.GIT_AUTHOR_NAME }} ${{ env.GIT_AUTHOR_EMAIL }}
# body: ${{ steps.pr_body.outputs.content }} # TODO(vdemeester) Write git status from the artifact