From d6fb45b417af9b8fd9709d9ff030715218ec0cb6 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Fri, 26 Jan 2024 11:36:41 +0100 Subject: [PATCH] Add pull-from and generate-pull-from-matrix actions Using one after the other should make creating a pull resources workflow very smooth. Signed-off-by: Vincent Demeester --- actions/generate-pull-from-matrix/action.yaml | 30 ++++++++++++ actions/pull-from/action.yaml | 47 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 actions/generate-pull-from-matrix/action.yaml create mode 100644 actions/pull-from/action.yaml diff --git a/actions/generate-pull-from-matrix/action.yaml b/actions/generate-pull-from-matrix/action.yaml new file mode 100644 index 00000000..ffbc0a72 --- /dev/null +++ b/actions/generate-pull-from-matrix/action.yaml @@ -0,0 +1,30 @@ +--- +name: Generate `pull-from` matrix output +description: | + Generates a GitHub Worklow outputs that can then be consumed with `strategy.matrix` from an `externals.yaml` file. +inputs: + version: + description: 'Version of catalog-cd to install (tip, latest-release, v0.1.0, etc.)' + require: false + default: 'latest-release' + externals: + description: | + Path to the `externals.yaml` file + required: true + default: ./externals.yaml +outputs: + pull-from-list: + description: | + `stragety.matrix` compatible output containing the "matrix" of pull-from to run. +runs: + using: composite + steps: + - uses: openshift-pipelines/catalog-cd/actions/setup-catalog-cd + with: + version: ${{ inputs.version }} + - id: set-matrix + name: Generate catalog matrix + run: | + set -Eeu + echo "pull-from-list=$(catalog-cd catalog externals --config ./externals.yaml)" >> "$GITHUB_OUTPUT" + cat "$GITHUB_OUTPUT" diff --git a/actions/pull-from/action.yaml b/actions/pull-from/action.yaml new file mode 100644 index 00000000..ef412fb9 --- /dev/null +++ b/actions/pull-from/action.yaml @@ -0,0 +1,47 @@ +--- +name: Generate `pull-from` matrix output +description: | + Generates a GitHub Worklow outputs that can then be consumed with `strategy.matrix` from an `externals.yaml` file. +inputs: + version: + description: 'Version of catalog-cd to install (tip, latest-release, v0.1.0, etc.)' + require: false + default: 'latest-release' + name: + description: 'Name of the repository we pull' + required: true + url: + description: 'URL of the repository we pull' + required: true + type: + description: 'Type of resources we pull' + required: true + default: 'task' + ignoreVersions: + description: 'Versions to ignore' + required: 'true' + default: '' + target: + description: 'The path where catalog-cd will write the resources pulled' + required: true + default: . +outputs: + pull-from-list: + description: | + `stragety.matrix` compatible output containing the "matrix" of pull-from to run. +runs: + using: composite + steps: + - uses: openshift-pipelines/catalog-cd/actions/setup-catalog-cd + with: + version: ${{ inputs.version }} + - id: set-matrix + name: Generate catalog matrix + run: | + set -Eeu + catalog-cd catalog generate-from \ + --name ${{ inputs.name }} \ + --url ${{ inputs.url }} \ + --type ${{ inputs.type }} \ + --ignore-versions "${{ inputs.ignoreVersions }}" \ + ${{ inputs.target }}