Skip to content

generate-catalogs #1842

generate-catalogs

generate-catalogs #1842

---
# This workflow generates the stable catalog and pushes it to
# the publish branch.
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 == 'openshift-pipelines' # do not run this elsewhere
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: openshift-pipelines/catalog-cd/actions/setup-catalog-cd@main
- id: set-matrix
name: Generate catalog matrix
run: |
set -Eeu
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 == 'openshift-pipelines' # do not run this elsewhere
strategy:
matrix: ${{fromJSON(needs.catalog-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 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: |
set -Eeu
mkdir -p stable/tasks stable/pipelines stable/stepactions
cp -fRv tasks/* stable/tasks
cp -fRv pipelines/* stable/pipelines
cp -fRv stepactions/* stable/stepactions
catalog-cd catalog generate-from \
--name ${{ matrix.name }} \
--url ${{ matrix.url }} \
--type ${{ matrix.type }} \
--ignore-versions "${{ matrix.ignoreVersions }}" \
stable
- name: Checkout "p" publish branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
repository: openshift-pipelines/tektoncd-catalog
ref: p
path: p
- name: Copy "partial" catalog ${{ matrix.name }} in publish branch
run: |
cp -fRv stable/* p/
- name: Add ${{ matrix.type }} from ${{ matrix.name }} to publish branch
working-directory: p
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 stepactions
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@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v5
with:
path: p
base: p
branch: update-stable-${{ 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
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
name: ${{ matrix.name }}-${{ matrix.type }}-stable-catalog-artifact
path: p/
retention-days: 3 # We don't need to keep them for long