Skip to content

Commit 50dc453

Browse files
committed
Merge branch 'issue-1290' of https://github.com/ferishili/opencast-admin-interface into issue-1290
2 parents 461767b + 7830b82 commit 50dc453

115 files changed

Lines changed: 4765 additions & 2089 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/demo-page.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/get-release-server.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
if [ $# -ne 1 ]; then
4+
echo "Usage: $0 OC_VERSION"
5+
echo " eg: $0 r/16.x -> Returns the current correct server for r/16.x"
6+
exit 1
7+
fi
8+
9+
git clone https://github.com/opencast/opencast.git ~/opencast
10+
cd ~/opencast
11+
12+
#Get the list of *all* branches in the format remotes/origin/r/N.m
13+
#grep for r/N.x
14+
#then use cut to remove remotes/origin
15+
#then use sort, with a field delimiter of '/', sorting on the *second* key in 'n'umeric 'r'evers order
16+
#then only consider the first 3 entries
17+
ary=( develop `git branch -a | grep origin | grep 'r/[0-9]*.x' | cut -f 3- -d '/' | sort -t '/' -k 2nr | head -n 3` )
18+
19+
#Iterate through the array above.
20+
#If the script input matches the first item, spit out develop
21+
#If the script iput matches hte second item... etc
22+
#If it doesn't match anything, then don't say anything
23+
for i in "${!ary[@]}"
24+
do
25+
if [[ "${ary[i]}" = "$1" ]]; then
26+
if [[ $i -eq 0 ]]; then
27+
echo "develop.opencast.org"
28+
exit 0
29+
elif [[ $i -eq 1 ]]; then
30+
echo "stable.opencast.org"
31+
exit 0
32+
elif [[ $i -eq 2 ]]; then
33+
echo "legacy.opencast.org"
34+
exit 0
35+
fi
36+
fi
37+
done
Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
11
on:
2-
push:
3-
tags:
4-
- '*-*-*'
2+
workflow_dispatch:
53

6-
name: Create release draft
4+
name: Create release tag
75

86
jobs:
97
build:
10-
name: Create release from tag
8+
name: Create release tag
119
runs-on: ubuntu-latest
1210
steps:
1311
- name: checkout code
1412
uses: actions/checkout@v4
15-
16-
- name: get node.js
17-
uses: actions/setup-node@v4
1813
with:
19-
node-version: 20
14+
fetch-depth: 0
2015

21-
- name: download dependencies
22-
run: npm ci
16+
- name: prepare git
17+
run: |
18+
git config --global user.email 'cloud@opencast.org'
19+
git config --global user.name 'Release Bot'
2320
24-
- name: build release
21+
- name: tag and push
2522
env:
26-
PUBLIC_URL: /admin-ui
27-
run: npm run build
28-
29-
- name: create release tarball
30-
working-directory: build
31-
run: tar -czf "../oc-admin-ui-$(date -u +%F).tar.gz" *
32-
33-
- name: create new release
34-
uses: softprops/action-gh-release@v2
35-
with:
36-
files: ./oc-admin-ui-*.tar.gz
37-
draft: true
38-
fail_on_unmatched_files: true
39-
generate_release_notes: true
23+
GH_TOKEN: ${{ github.token }}
24+
run: |
25+
#Translate 'develop' to 18.x or whatever is appropriate
26+
if [ "develop" == "${{ github.ref_name }}" ]; then
27+
#NB normally we only clone just the head ref, but fetch-depth: 0 above gets *all* the history
28+
export TEMP="$((`git branch -a | grep r/ | cut -f 4 -d '/' | cut -f 1 -d '.'` + 1)).x"
29+
else
30+
export TEMP=${{ github.ref_name }}
31+
fi
32+
export TAG=${TEMP#r\/}-`date +%Y-%m-%d`
33+
git tag $TAG
34+
git push origin $TAG
35+
sleep 2
36+
gh workflow run process-release.yml -r $TAG

.github/workflows/crowdin-upload-keys.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name: Crowdin » Upload keys
33
on:
44
push:
55
branches:
6-
- main
6+
- develop
7+
- r/*
78

89
concurrency:
910
group: crowdin-${{ github.ref }}

.github/workflows/deploy-main.yml

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,41 @@
1-
name: Publish Test Page
1+
name: Build & Deploy main brances
22

33
on:
44
push:
55
branches:
6-
- main
6+
- develop
7+
- r/*
78

89
concurrency:
9-
group: ${{ github.workflow }}-${{ github.ref }}
10-
cancel-in-progress: true
10+
group: ${{ github.workflow }}
11+
cancel-in-progress: false
1112

1213
jobs:
13-
build:
14+
detect:
1415
if: github.repository_owner == 'opencast'
1516
runs-on: ubuntu-latest
17+
outputs:
18+
server: ${{ steps.test-server.outputs.server }}
19+
branch: ${{ steps.branch-name.outputs.branch }}
20+
steps:
21+
- name: Checkout sources
22+
uses: actions/checkout@v4
23+
24+
- name: Determine the correct test server
25+
id: test-server
26+
run: echo "server=https://`./.github/get-release-server.sh ${{ github.ref_name }}`" >> $GITHUB_OUTPUT
27+
28+
- name: Determine branch name
29+
id: branch-name
30+
run: |
31+
#Temp becomes something like r/17.x
32+
export TEMP=${{ github.ref_name }}
33+
#Strip the r/ prefix, giving us just 17.x. If this is main/develop this does nothing
34+
echo "branch=${TEMP#r\/}" >> $GITHUB_OUTPUT
35+
36+
main:
37+
runs-on: ubuntu-latest
38+
needs: detect
1639
steps:
1740
- name: checkout code
1841
uses: actions/checkout@v4
@@ -26,40 +49,37 @@ jobs:
2649
run: npm ci
2750

2851
- name: build project
52+
run: |
53+
npm run build
2954
env:
55+
VITE_TEST_SERVER_URL: ${{needs.detect.outputs.server}}
3056
NODE_ENV: development
31-
VITE_TEST_SERVER_URL: "https://develop.opencast.org"
3257
VITE_TEST_SERVER_AUTH: "admin:opencast"
33-
run: npm run build
3458

35-
- name: create pages directory
36-
run: mkdir gh-pages
3759

38-
- name: include admin interface
39-
run: mv build gh-pages/admin-ui
60+
- name: Prepare git
61+
run: |
62+
git config --global user.name "Release Bot"
63+
git config --global user.email "cloud@opencast.org"
4064
41-
- name: include landing page
42-
run: cp .github/demo-page.html gh-pages/index.html
43-
44-
- name: upload test page artifact
45-
uses: actions/upload-pages-artifact@v3
46-
with:
47-
path: ./gh-pages
48-
49-
deploy:
50-
if: github.repository_owner == 'opencast'
51-
needs: build
52-
53-
permissions:
54-
pages: write
55-
id-token: write
56-
57-
environment:
58-
name: github-pages
59-
url: ${{ steps.deployment.outputs.page_url }}
65+
- name: Commit new version
66+
run: |
67+
git fetch --unshallow origin gh-pages
68+
git checkout gh-pages
69+
# Update gh-pages
70+
rm -rf $BRANCH
71+
mv build $BRANCH
72+
#Generate an index, in case anyone lands at the root of the test domain
73+
echo '<html><body><ul>' > index.html
74+
find . -mindepth 1 -maxdepth 1 -type d \
75+
| grep '[0-9]*.x\|develop' \
76+
| sort -r \
77+
| sed 's/^\(.*\)$/<li><a href=\1>\1<\/a><\/li>/' >> index.html
78+
echo '</ul></body></html>' >> index.html
79+
git add $BRANCH index.html
80+
git diff --staged --quiet || git commit --amend -m "Build $(date)"
81+
env:
82+
BRANCH: ${{needs.detect.outputs.branch}}
6083

61-
runs-on: ubuntu-latest
62-
steps:
63-
- name: deploy to GitHub Pages
64-
id: deployment
65-
uses: actions/deploy-pages@v4
84+
- name: Push updates
85+
run: git push origin gh-pages --force

.github/workflows/deploy-test.yml

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,46 @@ concurrency:
1111
cancel-in-progress: false
1212

1313
jobs:
14+
detect:
15+
if: ${{ github.event.pull_request.head.repo.full_name == 'opencast/opencast-admin-interface' }}
16+
runs-on: ubuntu-latest
17+
outputs:
18+
server: ${{ steps.test-server.outputs.server }}
19+
branch: ${{ steps.branch-name.outputs.branch }}
20+
steps:
21+
- name: Checkout sources
22+
uses: actions/checkout@v4
23+
with:
24+
ref: ${{github.event.pull_request.head.ref}}
25+
repository: ${{github.event.pull_request.head.repo.full_name}}
26+
27+
- name: Determine the correct test server
28+
id: test-server
29+
run: echo "server=https://`./.github/get-release-server.sh ${{ github.ref_name }}`" >> $GITHUB_OUTPUT
30+
31+
- name: Determine branch name
32+
id: branch-name
33+
run: |
34+
#Temp becomes something like r/17.x
35+
export TEMP=${{ github.ref_name }}
36+
#Strip the r/ prefix, giving us just 17.x. If this is main/develop this does nothing
37+
echo "branch=${TEMP#r\/}" >> $GITHUB_OUTPUT
38+
1439
main:
1540
runs-on: ubuntu-latest
41+
needs: detect
1642
steps:
1743
- name: generate build path
18-
run: echo "::set-output name=build::${{github.event.number}}/$(date +%Y-%m-%d_%H-%M-%S)/" | sed 's_build::/*_build::_'
44+
run: echo "build=${{github.event.number}}/$(date +%Y-%m-%d_%H-%M-%S)/" >> $GITHUB_OUTPUT
1945
id: build-path
2046

2147
- name: checkout code
2248
uses: actions/checkout@v4
2349
with:
24-
ref: ${{ github.event.pull_request.head.ref }}
25-
repository: ${{ github.event.pull_request.head.repo.full_name }}
50+
ref: ${{github.event.pull_request.head.ref}}
51+
repository: ${{github.event.pull_request.head.repo.full_name}}
2652

27-
- name: get Node.js
53+
- name: get node.js
2854
uses: actions/setup-node@v4
2955
with:
3056
node-version: 20
@@ -33,12 +59,12 @@ jobs:
3359
run: npm ci
3460

3561
- name: build app
62+
run: |
63+
npm run build
3664
env:
37-
PUBLIC_URL: /${{ steps.build-path.outputs.build }}
65+
VITE_TEST_SERVER_URL: ${{needs.detect.outputs.server}}
3866
NODE_ENV: development
39-
VITE_TEST_SERVER_URL: "https://develop.opencast.org"
4067
VITE_TEST_SERVER_AUTH: "admin:opencast"
41-
run: npm run build
4268

4369
- name: prepare git
4470
run: |
@@ -63,20 +89,24 @@ jobs:
6389

6490
- name: clone repository
6591
run: |
66-
git clone "git@github.com:opencast/opencast-admin-interface-test.git" admin-interface-test
92+
git clone -b gh-pages "git@github.com:${{ github.repository_owner }}/opencast-admin-interface-test.git" admin-interface-test
6793
68-
- name: switch to gh-pages branch
69-
working-directory: admin-interface-test
94+
- name: store build
95+
env:
96+
DEPLOY_PATH: admin-interface-test/${{ steps.build-path.outputs.build }}
7097
run: |
71-
git checkout gh-pages
98+
mkdir -p ${DEPLOY_PATH}
99+
cp -rv build/* ${DEPLOY_PATH}
72100
73-
- name: store build
101+
- name: Cleanup test repository
74102
working-directory: admin-interface-test
75103
env:
76-
DEPLOY_PATH: ${{ steps.build-path.outputs.build }}
104+
GH_TOKEN: ${{ github.token }}
77105
run: |
78-
mkdir -p ${DEPLOY_PATH}
79-
cp -rv ../build/* ${DEPLOY_PATH}
106+
wget https://raw.githubusercontent.com/${{ github.repository_owner }}/opencast-admin-interface-test/main/.github/scripts/cleanup-deployments.sh
107+
bash cleanup-deployments.sh ${{ github.repository_owner }}/opencast-admin-interface
108+
rm -f cleanup-deployments.sh
109+
git add .
80110
81111
- name: generate index.html
82112
working-directory: admin-interface-test
@@ -91,12 +121,12 @@ jobs:
91121
working-directory: admin-interface-test
92122
run: |
93123
git add .
94-
git commit -m "Build ${{ steps.build-path.outputs.build }}"
124+
git commit --amend -m "Build ${{ steps.build-path.outputs.build }}"
95125
96126
- name: push updates
97127
working-directory: admin-interface-test
98128
run: |
99-
git push origin gh-pages
129+
git push origin gh-pages --force
100130
101131
- name: add comment with deployment location
102132
uses: thollander/actions-comment-pull-request@v3

0 commit comments

Comments
 (0)