Merge branch 'main' of https://github.com/shaka-project/shaka-player #12
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
name: Deploy demo app | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ["main", "tivo-mainline"] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: git-checkout | |
uses: actions/checkout@v2 | |
- name: Install dependencies | |
shell: bash | |
run: npm ci | |
- name: Build Shaka Player | |
shell: bash | |
run: python build/all.py | |
- name: Extract git version | |
shell: bash | |
run: | | |
echo $(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short HEAD)-uncompiled > demo-version | |
- name: Tag the Player version | |
shell: bash | |
run: | | |
DEMO_VERSION="$(cat demo-version)-uncompiled" | |
sed \ | |
-i lib/player.js \ | |
-e "s/\(shaka.Player.version\) = .*/\1 = '$DEMO_VERSION';/" | |
- name: Backup demo node modules | |
shell: bash | |
run: | | |
DEMO_NODE_MODULES=$(jq -r .shakaCustom.demoDeps[] package.json) | |
tar cf demo-modules.tar \ | |
$(echo "$DEMO_NODE_MODULES" | sed -e 's@^@node_modules/@') | |
- name: Delete unneeded files | |
shell: bash | |
run: rm -rf .git .github build externs test node_modules | |
- name: Restore demo node modules | |
shell: bash | |
run: | | |
tar xf demo-modules.tar | |
rm demo-modules.tar | |
- name: Temporarily save demo app tar | |
uses: actions/upload-artifact@v2 | |
with: | |
name: demo-app | |
path: ./ | |
retention-days: 1 | |
deploy: | |
name: Deploy to gh-pages | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Retrieve saved demo app | |
uses: actions/download-artifact@v2 | |
with: | |
name: demo-app | |
path: ./demo-app | |
- name: Remove .gitignore | |
shell: bash | |
run: | | |
rm demo-app/.gitignore | |
- name: Rename with release | |
shell: bash | |
run: | | |
mv demo-app $(cat demo-app/demo-version) | |
- name: Create demo index | |
shell: bash | |
run: | | |
echo "<html> | |
<head> | |
<title>Shaka player demos</title> | |
</head> | |
<body> | |
<h1>Shaka player demos</h1> | |
<hr> | |
<pre>" > index.html | |
# Loop through each directory in the current folder and create a link to it | |
for dir in */ ; do | |
echo "<a href=\"${dir}\">${dir}</a><br>" >> index.html | |
done | |
# Close the tags in the index.html file | |
echo "</pre> | |
<hr> | |
</body> | |
</html>" >> index.html | |
- name: Commit & Push changes | |
uses: actions-js/push@master | |
with: | |
github_token: ${{ secrets.TIVOBOT_GITHUB_ACTION_TOKEN }} | |
branch: gh-pages | |