From 8e88305a97bacffb85cc1b0b144a96d469dc352c Mon Sep 17 00:00:00 2001 From: Gustavo Lira e Silva Date: Fri, 4 Dec 2026 09:14:39 -0300 Subject: [PATCH 1/3] feat(ci): expose the lifecycle helper as a GitHub Action (RHIDP-19630) Reviewers of the overlays change asked for an action instead of curling scripts/lifecycle.ts in each workflow. .github/actions/lifecycle sets up the current Node LTS and runs the script, so other repositories can call uses: redhat-developer/rhdh/.github/actions/lifecycle@main with command (active-branches, previous-y-stream, is-eol), an optional stream and repository-url, and read steps..outputs.result. is-eol reports true or false instead of an exit code; any other failure, including bad input, fails the step. A remote action is checked out with its whole repository, so it runs the script from the same ref. The E2E Tests workflow smoke-tests the action (previous-y-stream 99.0 must answer an X.Y stream). Midstream runs on GitLab and keeps fetching the script directly. Co-Authored-By: Claude Opus 5.5 --- .github/actions/lifecycle/action.yml | 53 +++++++++++++++++++++++++++ .github/workflows/e2e-tests-lint.yaml | 19 ++++++++++ scripts/lifecycle.ts | 2 + 3 files changed, 74 insertions(+) create mode 100644 .github/actions/lifecycle/action.yml diff --git a/.github/actions/lifecycle/action.yml b/.github/actions/lifecycle/action.yml new file mode 100644 index 0000000000..33aab0d3f8 --- /dev/null +++ b/.github/actions/lifecycle/action.yml @@ -0,0 +1,53 @@ +name: "RHDH lifecycle" +description: "Runs scripts/lifecycle.ts: supported RHDH release branches, the previous Y-stream, or whether a stream is EOL, from the Red Hat Product Life Cycles API" + +inputs: + command: + description: "active-branches, previous-y-stream or is-eol" + required: true + stream: + description: "X.Y stream for previous-y-stream and is-eol" + required: false + default: "" + repository-url: + description: "Repository whose release-* branches are read (default: redhat-developer/rhdh)" + required: false + default: "" +outputs: + result: + description: "active-branches: space-separated branches, oldest first, then main. previous-y-stream: X.Y. is-eol: true or false" + value: ${{ steps.run.outputs.result }} + +runs: + using: "composite" + steps: + - name: Set up Node.js + uses: actions/setup-node@8fccf151e3ba8038c300f83b40c8fd1e94f9c5ce # v7.2.0 + with: + node-version: lts/* + + - name: Run scripts/lifecycle.ts + id: run + shell: bash + env: + COMMAND: ${{ inputs.command }} + STREAM: ${{ inputs.stream }} + LIFECYCLE_REPO_URL: ${{ inputs.repository-url }} + # A remote action is checked out with its whole repository. + SCRIPT: ${{ github.action_path }}/../../../scripts/lifecycle.ts + run: | + args=("${COMMAND}") + [[ -n "${STREAM}" ]] && args+=("${STREAM}") + status=0 + result=$(node "${SCRIPT}" "${args[@]}") || status=$? + if [[ "${COMMAND}" == "is-eol" && "${status}" -le 1 ]]; then + # is-eol answers through its exit code: 0 EOL, 1 not EOL or unknown. + result=$([[ "${status}" -eq 0 ]] && echo true || echo false) + status=0 + fi + if [[ "${status}" -ne 0 ]]; then + echo "::error::lifecycle.ts ${COMMAND} failed with exit code ${status}" + exit "${status}" + fi + echo "${COMMAND}: ${result}" + echo "result=${result}" >> "${GITHUB_OUTPUT}" diff --git a/.github/workflows/e2e-tests-lint.yaml b/.github/workflows/e2e-tests-lint.yaml index b5fac7f89f..061f3074a4 100644 --- a/.github/workflows/e2e-tests-lint.yaml +++ b/.github/workflows/e2e-tests-lint.yaml @@ -7,6 +7,7 @@ on: - 'scripts/lifecycle*.ts' - 'scripts/package.json' - 'scripts/tsconfig.lifecycle.json' + - '.github/actions/lifecycle/**' - '.shellcheckrc' push: branches: @@ -17,6 +18,7 @@ on: - 'scripts/lifecycle*.ts' - 'scripts/package.json' - 'scripts/tsconfig.lifecycle.json' + - '.github/actions/lifecycle/**' - '.shellcheckrc' permissions: @@ -63,6 +65,23 @@ jobs: yarn --cwd e2e-tests tsc -p ../scripts/tsconfig.lifecycle.json node --test scripts/lifecycle.test.ts + # Smoke-test the action other repositories use (RHIDP-19630). + - name: Run the lifecycle action + id: lifecycle + uses: ./.github/actions/lifecycle + with: + command: previous-y-stream + stream: "99.0" + + - name: Check the lifecycle action output + env: + RESULT: ${{ steps.lifecycle.outputs.result }} + run: | + [[ "${RESULT}" =~ ^[0-9]+\.[0-9]+$ ]] || { + echo "::error::expected an X.Y stream, got '${RESULT}'" + exit 1 + } + - name: Run ShellCheck working-directory: ./e2e-tests env: diff --git a/scripts/lifecycle.ts b/scripts/lifecycle.ts index b52584b20a..a04c0ead5c 100755 --- a/scripts/lifecycle.ts +++ b/scripts/lifecycle.ts @@ -12,6 +12,8 @@ * branch and previous-y-stream answers from the branches. Without git, * previous-y-stream and active-branches fail. * + * GitHub workflows can run it through .github/actions/lifecycle. + * * Requires Node 22.18+ and git, no packages. LIFECYCLE_API_URL, LIFECYCLE_REPO_URL * and LIFECYCLE_TODAY (YYYY-MM-DD) override the endpoint, the repository whose * release-* branches are read (default: redhat-developer/rhdh), and the date. From cc19940c7e030dfcb13e814c42a4b9b4aee9fd28 Mon Sep 17 00:00:00 2001 From: Gustavo Lira e Silva Date: Fri, 4 Dec 2026 09:50:08 -0300 Subject: [PATCH 2/3] fix(ci): run the lifecycle action on the project's Node version Review: take Node from rhdh's .nvmrc instead of lts/*, so the action is upgraded together with the rest of the project. setup-node resolves an absolute node-version-file, so the action reads it from its own checkout. Co-Authored-By: Claude Opus 5.5 --- .github/actions/lifecycle/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/lifecycle/action.yml b/.github/actions/lifecycle/action.yml index 33aab0d3f8..e511190510 100644 --- a/.github/actions/lifecycle/action.yml +++ b/.github/actions/lifecycle/action.yml @@ -24,7 +24,8 @@ runs: - name: Set up Node.js uses: actions/setup-node@8fccf151e3ba8038c300f83b40c8fd1e94f9c5ce # v7.2.0 with: - node-version: lts/* + # The project's Node version, so the action moves with the rest of rhdh. + node-version-file: ${{ github.action_path }}/../../../.nvmrc - name: Run scripts/lifecycle.ts id: run From 0877ce90b56855356eaac38a276289dc8d562b21 Mon Sep 17 00:00:00 2001 From: Gustavo Lira e Silva Date: Fri, 4 Dec 2026 10:08:00 -0300 Subject: [PATCH 3/3] docs(ci): reword the lifecycle action's result output Review suggestion. Co-Authored-By: Claude Opus 5.5 --- .github/actions/lifecycle/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/lifecycle/action.yml b/.github/actions/lifecycle/action.yml index e511190510..768625293d 100644 --- a/.github/actions/lifecycle/action.yml +++ b/.github/actions/lifecycle/action.yml @@ -15,7 +15,7 @@ inputs: default: "" outputs: result: - description: "active-branches: space-separated branches, oldest first, then main. previous-y-stream: X.Y. is-eol: true or false" + description: "Three possible outputs, depending on command used. 1. active-branches: space-separated list of branches, from oldest to newest, then main. 2. previous-y-stream: X.Y. 3. is-eol: true or false" value: ${{ steps.run.outputs.result }} runs: