Skip to content

Commit d36c1ea

Browse files
gregorydloganKatrinIhler
authored andcommitted
Reworked how github pages are generated. Caching did not work correctly across feature branches, so we switch to branch-based deploys. Since we don't care about the branch history (right?!), we rewrite the branch each time
1 parent 076a975 commit d36c1ea

2 files changed

Lines changed: 36 additions & 64 deletions

File tree

.github/demo-page.html

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

.github/workflows/deploy-main.yml

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,11 @@ on:
77
- r/*.x
88

99
concurrency:
10-
group: ${{ github.workflow }}-${{ github.ref }}
11-
cancel-in-progress: true
10+
group: ${{ github.workflow }}
1211

1312
jobs:
14-
detect:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- name: determine the correct test server
18-
run: echo "TEST_SERVER=`./.github/get-release-server.sh`" >> GITHUB_ENV
19-
2013
build:
2114
if: github.repository_owner == 'opencast'
22-
needs: detect
2315
runs-on: ubuntu-latest
2416
steps:
2517
- name: checkout code
@@ -33,54 +25,44 @@ jobs:
3325
- name: download dependencies
3426
run: npm ci
3527

28+
- name: determine the correct test server
29+
id: vite-url
30+
run: echo "VITE_TEST_SERVER_URL=`./.github/get-release-server.sh ${{ github.ref_name }}`" >> GITHUB_ENV
31+
3632
- name: build project
3733
env:
34+
VITE_TEST_SERVER_URL: ${{ steps.vite-url.outputs.VITE_TEST_SERVER_URL }}
3835
NODE_ENV: development
39-
VITE_TEST_SERVER_URL: ${{ TEST_SERVER }}
4036
VITE_TEST_SERVER_AUTH: "admin:opencast"
4137
run: npm run build
4238

43-
- name: restore cache
44-
id: cache-builds
45-
run: actions/cache/restore@v4
46-
with:
47-
path: gh-pages
48-
id: gh-pages
49-
50-
- name: create pages directory
51-
run: mkdir -p gh-pages
52-
53-
- name: include admin interface
54-
run: mv build gh-pages/${{ github.ref }}/admin-ui
55-
56-
- name: include landing page
57-
run: cp .github/demo-page.html gh-pages/index.html
58-
59-
- name: upload test page artifact
60-
uses: actions/upload-pages-artifact@v3
61-
with:
62-
path: ./gh-pages
63-
64-
- name: cache built artifacts
65-
uses: actions/cache@v4
66-
with:
67-
path: gh-pages
68-
id: gh-pages
69-
70-
deploy:
71-
if: github.repository_owner == 'opencast'
72-
needs: build
73-
74-
permissions:
75-
pages: write
76-
id-token: write
77-
78-
environment:
79-
name: github-pages
80-
url: ${{ steps.deployment.outputs.page_url }}
81-
82-
runs-on: ubuntu-latest
83-
steps:
84-
- name: deploy to GitHub Pages
85-
id: deployment
86-
uses: actions/deploy-pages@v4
39+
- name: Prepare git
40+
run: |
41+
git config --global user.name "Release Bot"
42+
git config --global user.email "cloud@opencast.org"
43+
44+
- name: Commit new version
45+
run: |
46+
git fetch origin
47+
git checkout gh-pages
48+
#Temp becomes something like r/17.x
49+
export TEMP=${{ github.ref_name }}
50+
#Strip the r/ prefix, giving us just 17.x. If this is main/develop this does nothing
51+
export TARGET=${TEMP#r\/}
52+
# Update gh-pages
53+
rm -rf $TARGET
54+
mkdir -p $TARGET
55+
cp -r build/* $TARGET
56+
#Generate an index, in case anyone lands at the root of the test domain
57+
echo '<html><body><ul>' > index.html
58+
find . -mindepth 1 -maxdepth 1 -type d \
59+
| grep -v .git \
60+
| sort -r \
61+
| sed 's/^\(.*\)$/<li><a href=\1>\1<\/a><\/li>/' >> index.html
62+
echo '</ul></body></html>' >> index.html
63+
git add $TARGET
64+
git diff --staged --quiet || git commit --amend -m "Build $(date)"
65+
66+
- name: Push updates
67+
run: |
68+
git push origin gh-pages --force

0 commit comments

Comments
 (0)