-
Notifications
You must be signed in to change notification settings - Fork 41
168 lines (141 loc) · 5.47 KB
/
Copy pathpr-deploy-test-branch.yml
File metadata and controls
168 lines (141 loc) · 5.47 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: PRs » Publish Pull Request Page
on:
pull_request:
types:
- opened
- synchronize
concurrency:
group: pull-request-page
cancel-in-progress: false
env:
NODE_VERSION: 24
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=https://`./.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-pr:
runs-on: ubuntu-latest
needs: detect-repo-owner
steps:
- name: Generate build path
run: echo "build=${{github.event.number}}/$(date +%Y-%m-%d_%H-%M-%S)/" >> $GITHUB_OUTPUT
id: build-path
- name: Checkout sources
uses: actions/checkout@v5
- name: Ensure our node version matches the main repo's version
run: |
[[ "$(curl -s https://raw.githubusercontent.com/opencast/opencast/refs/heads/${{ github.base_ref }}/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@v5
with:
node-version: $NODE_VERSION
- name: Run npm ci
run: npm ci
- name: Build the app
run: |
npm run build
env:
VITE_TEST_SERVER_URL: ${{needs.detect-repo-owner.outputs.server}}
NODE_ENV: development
VITE_TEST_SERVER_AUTH: "admin:opencast"
- name: Prepare git
run: |
git config --global user.name "Admin Interface Deployment Bot"
git config --global user.email "cloud@opencast.org"
- name: Prepare GitHub SSH key from org level secret
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY_TEST }}
run: |
install -dm 700 ~/.ssh/
echo "${DEPLOY_KEY}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Wait for previous workflows to finish
uses: softprops/turnstyle@v3
with:
same-branch-only: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clone repository
run: |
git clone -b gh-pages "git@github.com:${{ github.repository_owner }}/admin-interface-test.git" admin-interface-test
- name: Store build in the clone
env:
DEPLOY_PATH: admin-interface-test/${{ steps.build-path.outputs.build }}
run: |
mkdir -p ${DEPLOY_PATH}
cp -rv build/* ${DEPLOY_PATH}
- name: Cleanup test repository
working-directory: admin-interface-test
env:
GH_TOKEN: ${{ github.token }}
run: |
wget https://raw.githubusercontent.com/${{ github.repository_owner }}/admin-interface-test/main/.github/scripts/cleanup-deployments.sh
bash cleanup-deployments.sh ${{ github.repository_owner }}/admin-interface
rm -f cleanup-deployments.sh
git add .
- name: Generate index.html
working-directory: admin-interface-test
run: |
echo '<html><body><ul>' > index.html
find . -maxdepth 2 -name '*_*' -type d \
| sort -r \
| sed 's/^\(.*\)$/<li><a href=\1>\1<\/a><\/li>/' >> index.html
echo '</ul></body></html>' >> index.html
- name: Commit new version
working-directory: admin-interface-test
run: |
git add .
git commit --amend -m "Build ${{ steps.build-path.outputs.build }}"
- name: Force push admin interface test branch
working-directory: admin-interface-test
run: |
git push origin gh-pages --force
- name: Add comment with deployment location
uses: thollander/actions-comment-pull-request@v3
with:
comment-tag: static-test-deployment
message: >
This pull request is deployed at
[test.admin-interface.opencast.org/${{ steps.build-path.outputs.build }}
](https://test.admin-interface.opencast.org/${{ steps.build-path.outputs.build }}).
It might take a few minutes for it to become available.
check-no-modified-translations:
name: Translations only via Crowdin
if: github.repository_owner == 'opencast'
runs-on: ubuntu-latest
steps:
- name: Checkout Sources
uses: actions/checkout@v4
- name: Get changed locale files
uses: dorny/paths-filter@v4
id: filter_locales
with:
filters: | # !(pattern) matches anything but pattern
locales:
- 'src/i18n/org/opencastproject/adminui/languages/!lang-(en_US)*.json'
- name: Check for changes in translations
if: steps.filter_locales.outputs.locales == true
uses: actions/github-script@v9
with:
script: |
core.setFailed('You should not alter translations outside of Crowdin.')