-
Notifications
You must be signed in to change notification settings - Fork 47
101 lines (86 loc) · 3.41 KB
/
deploy-main-branches.yml
File metadata and controls
101 lines (86 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Build » Deploy main branches
on:
push:
branches:
- develop
- r/*
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
jobs:
detect-repo-owner:
if: github.repository_owner == 'opencast'
runs-on: ubuntu-latest
outputs:
server: ${{ steps.test-server.outputs.server }}
branch: ${{ steps.branch-name.outputs.branch }}
steps:
- name: Checkout sources
uses: actions/checkout@v5
- name: Determine the correct test server
id: test-server
run: echo "server=`./.github/get-release-server.sh ${{ github.ref_name }}`" >> $GITHUB_OUTPUT
- name: Determine branch name
id: branch-name
run: |
#Temp becomes something like r/17.x
export TEMP=${{ github.ref_name }}
#Strip the r/ prefix, giving us just 17.x. If this is main/develop this does nothing
echo "branch=${TEMP#r\/}" >> $GITHUB_OUTPUT
deploy-main-branches:
runs-on: ubuntu-latest
needs: detect-repo-owner
steps:
- name: Checkout sources
uses: actions/checkout@v5
- name: Get Node.js
uses: actions/setup-node@v5
with:
node-version: 20
- name: Run npm ci
run: npm ci
- name: Build the app
run: |
# This set the editor's datasource to the relevant test server
sed -i "s#develop.opencast.org#$SERVER#g" public/editor-settings.toml
npm run build
env:
SERVER: ${{needs.detect-repo-owner.outputs.server}}
PUBLIC_URL: ${{needs.detect-repo-owner.outputs.branch}}
VITE_APP_SETTINGS_PATH: editor-settings.toml
# tests are currently failing
#- run: npm test
# env:
# CI: true
- name: Prepare git
run: |
git config --global user.name "Editor Deployment Bot"
git config --global user.email "cloud@opencast.org"
- name: Commit new version
run: |
git checkout -- public/editor-settings.toml
git fetch --unshallow origin gh-pages
git checkout gh-pages
# Update gh-pages
rm -rf $BRANCH
mv build $BRANCH
#Generate an index, in case anyone lands at the root of the test domain
echo $'<html><head><link rel=stylesheet type=text/css href=assets/index.css /></head><body><div class="head-container"><img src=assets/opencast-white.svg /></div><div class="navbar-container"></div><div class="text-container"><p>Deployment for the latest development versions of the Opencast editor.The branches listed here correspond to Opencast\'s own branches.</br><b>Please select a version.</b></p></div><ul>' > index.html
find . -mindepth 1 -maxdepth 1 -type d \
| grep '[0-9]*.x\|develop' \
| sort -r \
| sed 's/^\(.*\)$/<li><a href=\1>\1<\/a><\/li>/' >> index.html
echo '</ul></body></html>' >> index.html
git add $BRANCH index.html
git diff --staged --quiet || git commit --amend -m "Build $(date)"
env:
BRANCH: ${{needs.detect-repo-owner.outputs.branch}}
- name: update CSS and other assets
if: github.ref == 'refs/heads/develop'
run: |
rm -rf assets
mv assets_temp assets
git add assets
git diff --staged --quiet || git commit --amend -m "Build $(date)"
- name: Push updates
run: git push origin gh-pages --force