Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/actions/lifecycle/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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"
Comment thread
nickboldt marked this conversation as resolved.
Resolved
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: "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:
using: "composite"
steps:
- name: Set up Node.js
uses: actions/setup-node@8fccf151e3ba8038c300f83b40c8fd1e94f9c5ce # v7.2.0
with:
# 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
shell: bash
Comment thread
nickboldt marked this conversation as resolved.
Resolved
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
Comment thread
gustavolira marked this conversation as resolved.
Resolved
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}"
19 changes: 19 additions & 0 deletions .github/workflows/e2e-tests-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- 'scripts/lifecycle*.ts'
- 'scripts/package.json'
- 'scripts/tsconfig.lifecycle.json'
- '.github/actions/lifecycle/**'
- '.shellcheckrc'
push:
branches:
Expand All @@ -17,6 +18,7 @@ on:
- 'scripts/lifecycle*.ts'
- 'scripts/package.json'
- 'scripts/tsconfig.lifecycle.json'
- '.github/actions/lifecycle/**'
- '.shellcheckrc'

permissions:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions scripts/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading