generate-experimental-catalogs #217
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# This workflow generates the experimental catalog and pushes it to | |
# the publish branch. | |
name: generate-experimental-catalogs | |
on: | |
schedule: | |
- cron: "0 */6 * * *" # every 6 hours | |
workflow_dispatch: | |
# allow manual triggering | |
jobs: | |
experimental-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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 | |
with: | |
go-version: 1.20.x | |
cache: true | |
- id: set-matrix | |
name: Generate catalog matrix | |
run: | | |
set -Eeu | |
echo "matrix=$(go run ./cmd/catalog-cd catalog externals --config ./experimental/externals.yaml)" >> "$GITHUB_OUTPUT" | |
cat "$GITHUB_OUTPUT" | |
generate-experimental-catalog: | |
needs: experimental-catalog-matrix | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere | |
strategy: | |
matrix: ${{fromJSON(needs.experimental-catalog-matrix.outputs.matrix)}} | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 | |
with: | |
go-version: 1.20.x | |
cache: true | |
- name: ${{ matrix.type }} catalog for ${{ matrix.name }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mkdir -p experimental/tasks experimental/pipelines | |
go run ./cmd/catalog-cd catalog generate-from \ | |
--name ${{ matrix.name }} \ | |
--url ${{ matrix.url }} \ | |
--type ${{ matrix.type }} \ | |
--ignore-versions "${{ matrix.ignoreVersions }}" \ | |
experimental | |
- name: Checkout "p" publish branch | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
with: | |
repository: openshift-pipelines/tektoncd-catalog | |
ref: p | |
path: p | |
- name: Copy "partial" catalog ${{ matrix.name }} in publish branch | |
run: | | |
cp -fRv experimental/tasks/* p/experimental/tasks | |
cp -fRv experimental/pipelines/* p/experimental/pipelines | |
- 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 experimental/tasks experimental/pipelines | |
git commit -m "experimental/${{ 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: | |
path: p | |
base: p | |
branch: update-experimental-${{ matrix.name }}-${{ matrix.type }} | |
delete-branch: true | |
add-paths: README.md # This is here just to force it to not commit anything | |
title: "experimental/${{ 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@1eb3cb2b3e0f29609092a73eb033bb759a334595 # v4 | |
with: | |
name: ${{ matrix.name }}-${{ matrix.type }}-experimental-catalog-artifact | |
path: p/experimental/ | |
retention-days: 3 # We don't need to keep them for long |