forked from opencast/opencast-admin-interface
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opencast#472 from lkiesow/test-deployment
Automatically deploy pull requests
- Loading branch information
Showing
2 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Publish Pull Request Page | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: generate build path | ||
run: echo "::set-output name=build::${{github.event.number}}/$(date +%Y-%m-%d_%H-%M-%S)/" | sed 's_build::/*_build::_' | ||
id: build-path | ||
|
||
- name: checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
|
||
- name: get Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: download dependencies | ||
run: npm ci | ||
|
||
- name: build app | ||
run: npm run build | ||
env: | ||
PUBLIC_URL: /${{ steps.build-path.outputs.build }} | ||
CI: false | ||
|
||
- name: prepare git | ||
run: | | ||
git config --global user.name "Admin Interface Deployment Bot" | ||
git config --global user.email "[email protected]" | ||
- name: prepare GitHub SSH key | ||
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@v1 | ||
with: | ||
same-branch-only: false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: clone repository | ||
run: | | ||
git clone "[email protected]:opencast/opencast-admin-interface-test.git" admin-interface-test | ||
- name: switch to gh-pages branch | ||
working-directory: admin-interface-test | ||
run: | | ||
git checkout gh-pages | ||
- name: include mock data | ||
working-directory: admin-interface-test | ||
run: cp -rv ../test/GET/* . | ||
|
||
- name: store build | ||
working-directory: admin-interface-test | ||
env: | ||
DEPLOY_PATH: ${{ steps.build-path.outputs.build }} | ||
run: | | ||
mkdir -p ${DEPLOY_PATH} | ||
cp -rv ../build/* ${DEPLOY_PATH} | ||
- 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 -m "Build ${{ steps.build-path.outputs.build }}" | ||
- name: push updates | ||
working-directory: admin-interface-test | ||
run: | | ||
git push origin gh-pages | ||
- name: add comment with deployment location | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
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. |