Skip to content

Update plugins repository references #770

Update plugins repository references

Update plugins repository references #770

name: Update plugins repository references
on:
workflow_dispatch:
inputs:
regexps:
description: line-separated list of regular expressions of the plugin packages to discover. An expression surrounded by single quotes is taken as a litteral package name.
type: string
required: false
default: ""
workspace-path:
description: relative path of a workspace the discovery should be focused on
type: string
required: false
default: ""
allow-workspace-addition:
description: allow creating PRs that will add workspaces
type: boolean
required: false
release-branch-pattern:
description: A regular expression that defines active release branches. If not provided, the last 2 release branches (release-x.x) will be used.
type: string
required: false
default: ""
single-branch:
description: If provided, only the specified branch will receive updates, but the release branch pattern will still be used to find the minimum target backstage version.
type: string
required: false
default: ""
pr-to-update:
description: optional PR number of a PR to update
type: string
required: false
default: ""
verbose:
description: enable verbose logs
type: boolean
required: false
default: false
debug:
description: enable debug mode in bash scripts
type: boolean
required: false
default: false
workflow_call:
inputs:
regexps:
description: line-separated list of regular expressions of the plugin packages to discover. An expression surrounded by single quotes is taken as a litteral package name.
type: string
required: false
default: ""
workspace-path:
description: relative path of a workspace the discovery should be focused on
type: string
required: false
default: ""
pr-to-update:
type: string
required: false
default: ""
allow-workspace-addition:
description: allow creating PRs that will add workspaces
type: boolean
required: false
release-branch-pattern:
description: A regular expression that defines active release branches. If not provided, the last 2 release branches (release-x.x) will be used.
type: string
required: false
default: ""
single-branch:
description: If provided, only the specified branch will receive updates, but the release branch pattern will still be used to find the minimum target backstage version.
type: string
required: false
default: ""
verbose:
description: enable verbose logs
type: boolean
required: false
default: false
debug:
description: enable debug mode in bash scripts
type: boolean
required: false
default: false
schedule:
- cron: '0 12 * * *'
- cron: '0 19 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ inputs.pr-to-update }}
cancel-in-progress: true
jobs:
prepare:
runs-on: ubuntu-latest
name: Prepare
outputs:
regexps: ${{ steps.read-regexps.outputs.REGEXPS }}
release-branch-pattern: ${{ steps.read-release-branch-pattern.outputs.RELEASE_BRANCH_PATTERN }}
steps:
- uses: actions/[email protected]
- name: Read Regexps
id: read-regexps
env:
INPUT_REGEXPS: ${{ inputs.regexps }}
shell: bash
run: |
REGEXPS="${INPUT_REGEXPS}"
if [[ "${REGEXPS}" == "" ]]
then
REGEXPS="$(cat plugins-regexps)"
fi
echo "Regexps of plugins to export:"
echo "$REGEXPS"
echo "REGEXPS=$(echo $REGEXPS | tr '\n' ' ')" >> $GITHUB_OUTPUT
- name: Read Release Branch Pattern
id: read-release-branch-pattern
env:
INPUT_RELEASE_BRANCH_PATTERN: ${{ inputs.release-branch-pattern }}
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
RELEASE_BRANCH_PATTERN="${INPUT_RELEASE_BRANCH_PATTERN}"
if [[ "${RELEASE_BRANCH_PATTERN}" == "" ]]
then
# Get the last 2 release branch names, sorted by version, and build a regex like ^release-(1\.7|1\.8)$
RELEASE_BRANCH_PATTERN="$(gh api repos/${GITHUB_REPOSITORY}/branches | \
jq -r '[.[].name | select(test("^release-")) | sub("^release-";"")]
| sort_by(split(".") | map(tonumber))
| reverse
| .[:2]
| map(gsub("\\."; "\\."))
| "^release-(" + join("|") + ")$"')"
fi
echo "Release branch pattern: ${RELEASE_BRANCH_PATTERN}"
echo "RELEASE_BRANCH_PATTERN=${RELEASE_BRANCH_PATTERN}" >> $GITHUB_OUTPUT
update-branches:
name: Update Branches
needs: prepare
if: github.event_name != 'schedule'
uses: redhat-developer/rhdh-plugin-export-utils/.github/workflows/update-plugins-repo-refs.yaml@main
with:
regexps: ${{ needs.prepare.outputs.regexps }}
workspace-path: ${{ inputs.workspace-path }}
pr-to-update: ${{ inputs.pr-to-update }}
overlay-repo: ${{ github.repository }}
release-branch-pattern: ${{ needs.prepare.outputs.release-branch-pattern }}
single-branch: ${{ inputs.single-branch }}
verbose: ${{ inputs.verbose != '' && inputs.verbose }}
debug: ${{ inputs.debug != '' && inputs.debug }}
allow-workspace-addition: ${{ inputs.allow-workspace-addition != '' && inputs.allow-workspace-addition }}
permissions:
contents: write
pull-requests: write
update-release-branches:
name: Update Release Branches
needs: prepare
if: >-
(github.event_name == 'schedule' && github.event.schedule == '0 12 * * *')
uses: redhat-developer/rhdh-plugin-export-utils/.github/workflows/update-plugins-repo-refs.yaml@main
with:
regexps: ${{ needs.prepare.outputs.regexps }}
overlay-repo: ${{ github.repository }}
release-branch-pattern: ${{ needs.prepare.outputs.release-branch-pattern }}
single-branch: "" # we want to update all release branches
verbose: false
debug: false
allow-workspace-addition: false
permissions:
contents: write
pull-requests: write
update-main-branch:
name: Update Main Branch
needs: prepare
if: >-
(github.event_name == 'schedule' && github.event.schedule == '0 19 * * *')
uses: redhat-developer/rhdh-plugin-export-utils/.github/workflows/update-plugins-repo-refs.yaml@main
with:
regexps: ${{ needs.prepare.outputs.regexps }}
overlay-repo: ${{ github.repository }}
release-branch-pattern: ${{ needs.prepare.outputs.release-branch-pattern }}
single-branch: "main" # we want to update only the main branch
verbose: false
debug: false
allow-workspace-addition: true
permissions:
contents: write
pull-requests: write