Merge branch 'r/19.x' into develop #65
This file contains hidden or 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: Build » Deploy main branches | |
| # NOTE: This should *not* run on tags, these are handled in the main repo | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - r/* | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| cancel-in-progress: false | |
| jobs: | |
| detect-repo-owner: | |
| name: Detect branch and appropriate server | |
| 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-main-branches: | |
| name: Deploy admin-interface.opencast.org | |
| 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: | | |
| 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: Commit new version | |
| run: | | |
| # Save the current assets from the main branch | |
| mv .github/assets assets_temp | |
| # Update and change to the gh-pages branch | |
| 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 admin interface.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 | |
| file-upstream-admin-pr: | |
| name: Create upstream admin PR to incorporate build | |
| runs-on: ubuntu-latest | |
| needs: detect-repo-owner | |
| permissions: | |
| contents: write # For the release | |
| pull-requests: write # For the PR in the upstream repo | |
| steps: | |
| - name: Prepare git | |
| run: | | |
| git config --global user.name "Admin Interface Commit Bot" | |
| git config --global user.email "cloud@opencast.org" | |
| - name: Prepare GitHub SSH key | |
| env: | |
| DEPLOY_KEY: ${{ secrets.MODULE_PR_DEPLOY_KEY }} | |
| run: | | |
| install -dm 700 ~/.ssh/ | |
| echo "${DEPLOY_KEY}" > ~/.ssh/id_ed25519 | |
| chmod 600 ~/.ssh/id_ed25519 | |
| ssh-keyscan github.com >> ~/.ssh/known_hosts | |
| - name: Clone upstream repository | |
| run: | | |
| git clone -b ${{ github.ref_name }} "git@github.com:${{ github.repository_owner }}/opencast.git" opencast | |
| cd opencast | |
| git checkout -b t/admin-${{ needs.detect-repo-owner.outputs.branch }} | |
| - name: Update the admin submodule | |
| working-directory: opencast | |
| run: | | |
| # Note: This could be a race condition in that rapid submodule pushes can trigger multiple PRs in short order | |
| # and we don't have a guarantee that the update triggered by commit A does not end up finding commit B | |
| # We are going to ignore this possibility since we almost universally want the *latest* commit, though this | |
| # could end up causing the commit message, and the actual submodule hash to differ. | |
| git submodule update --init --remote modules/admin | |
| git add modules/admin | |
| git commit -m "Updating admin-service to ${{ github.sha }}" | |
| # This token is an account wide token which allows creation of PRs and pushes. | |
| echo "${{ secrets.MODULE_PR_TOKEN }}" > token.txt | |
| gh auth login --with-token < token.txt | |
| export CURRENT_PR=$(gh pr list -R ${{ github.repository_owner }}/opencast --head t/admin-${{ needs.detect-repo-owner.outputs.branch }} --json number --jq '.[].number') | |
| git push origin t/admin-${{ needs.detect-repo-owner.outputs.branch }} --force | |
| if [ -n "$CURRENT_PR" ]; then | |
| gh pr edit $CURRENT_PR \ | |
| --body "Updating Opencast ${{ needs.detect-repo-owner.outputs.branch }} Admin Interface module to [${{ github.sha }}](https://github.com/${{ github.repository_owner }}/admin-interface/commit/${{ github.sha }})" \ | |
| -R ${{ github.repository_owner }}/opencast | |
| else | |
| gh pr create \ | |
| --title "Update ${{ needs.detect-repo-owner.outputs.branch }} Admin Interface" \ | |
| --body "Updating Opencast ${{ needs.detect-repo-owner.outputs.branch }} Admin Interface module to [${{ github.sha }}](https://github.com/${{ github.repository_owner }}/admin-interface/commit/${{ github.sha }})" \ | |
| --head=${{ github.repository_owner }}:t/admin-${{ needs.detect-repo-owner.outputs.branch }} \ | |
| --base ${{ github.ref_name }} \ | |
| -R ${{ github.repository_owner }}/opencast | |
| #FIXME: fine grained PATs can't apply labels | |
| #FIXME: classic PATs don't have the permissions because the PR isn't in an opencastproject (the user) repo | |
| #--label admin-ui --label maintenance \ | |
| fi |