Skip to content
Open
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
32 changes: 32 additions & 0 deletions .github/actions/setup-node-from-opencast/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Set up Node.js like Opencast
description: Install the Node.js version declared as <node.version> in the pom.xml of the matching Opencast branch

inputs:
branch:
description: Branch of this repository. The Node.js version of the Opencast branch with the same name is used, or the one of develop if there is no such branch.
required: true

runs:
using: composite
steps:
- name: determine node.js version
id: opencast
shell: bash
env:
BRANCH: ${{ inputs.branch }}
run: |
set -eu
# Only develop and the release branches exist in Opencast
case "${BRANCH}" in
develop|r/*) ;;
*) BRANCH=develop ;;
esac
curl -fsS "https://raw.githubusercontent.com/opencast/opencast/refs/heads/${BRANCH}/pom.xml" -o "${RUNNER_TEMP}/opencast-pom.xml"
version="$(sed -n 's/.*<node\.version>v\{0,1\}\([^<]*\)<.*/\1/p' "${RUNNER_TEMP}/opencast-pom.xml" | head -n1)"
test -n "${version}"
echo "Using Node.js ${version} from the pom.xml of Opencast ${BRANCH}"
echo "version=${version}" >> "${GITHUB_OUTPUT}"

- uses: actions/setup-node@v7
with:
node-version: ${{ steps.opencast.outputs.version }}
16 changes: 3 additions & 13 deletions .github/workflows/deploy-main-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

env:
NODE_VERSION: 24

jobs:
detect-repo-owner:
name: Detect branch and appropriate server
Expand Down Expand Up @@ -47,17 +44,10 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v7

- name: Ensure our node version matches the main repo's version
run: |
[[ "$(curl -s https://raw.githubusercontent.com/opencast/opencast/refs/heads/${{ github.ref_name }}/pom.xml | \
grep node.version | grep -Eo 'v[0-9.]+' | cut -f 1 -d '.' | cut -c 2-)" == "$NODE_VERSION" ]] \
&& exit 0 \
|| (echo "Node version does not match"; exit 1)

- name: Get Node.js
uses: actions/setup-node@v7
- name: Get Node.js in the version Opencast uses
uses: ./.github/actions/setup-node-from-opencast
with:
node-version: ${{ env.NODE_VERSION }}
branch: ${{ github.ref_name }}

- name: Run npm ci
run: npm ci
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/pr-build-test-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ concurrency:
group: pull-request-page
cancel-in-progress: false

env:
NODE_VERSION: 24

jobs:
detect-repo-owner:
if: github.repository_owner == 'opencast'
Expand Down Expand Up @@ -47,10 +44,10 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v7

- name: Get Node.js
uses: actions/setup-node@v7
- name: Get Node.js in the version Opencast uses
uses: ./.github/actions/setup-node-from-opencast
with:
node-version: ${{ env.NODE_VERSION }}
branch: ${{ github.base_ref }}

- name: Run npm ci
run: npm ci
Expand Down
27 changes: 3 additions & 24 deletions .github/workflows/pr-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,17 @@ on:
- 'dependabot/**'
pull_request:

env:
NODE_VERSION: 24

jobs:
check-npm-build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v7

- name: Ensure our node version matches the main repo's version for pull requests
if: github.event_name == 'pull_request'
run: |
curl -s https://raw.githubusercontent.com/opencast/opencast/refs/heads/${{ github.base_ref }}/pom.xml -o pom.xml
export FOUND_VERSION="$(grep node.version pom.xml | grep -Eo 'v[0-9.]+' | cut -f 1 -d '.' | cut -c 2-)"
[[ "$FOUND_VERSION" == "$NODE_VERSION" ]] \
&& exit 0 \
|| (echo "Node version does not match. Expected $NODE_VERSION, found $FOUND_VERSION"; exit 1)

- name: Ensure our node version matches the main repo's version for push events
if: github.event_name == 'push' && (startsWith('r/', github.ref_name) || 'develop' == github.ref_name)
run: |
curl -s https://raw.githubusercontent.com/opencast/opencast/refs/heads/${{ github.ref_name }}/pom.xml -o pom.xml
export FOUND_VERSION="$(grep node.version pom.xml | grep -Eo 'v[0-9.]+' | cut -f 1 -d '.' | cut -c 2-)"
[[ "$FOUND_VERSION" == "$NODE_VERSION" ]] \
&& exit 0 \
|| (echo "Node version does not match. Expected $NODE_VERSION, found $FOUND_VERSION"; exit 1)

- name: Get Node.js
uses: actions/setup-node@v7
- name: Get Node.js in the version Opencast uses
uses: ./.github/actions/setup-node-from-opencast
with:
node-version: ${{ env.NODE_VERSION }}
branch: ${{ github.base_ref || github.ref_name }}

- name: Run npm ci
run: npm ci
Expand Down
Loading