feat: comments #50
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: PRs » Publish Pull Request Page | |
| on: | |
| pull_request_target: | |
| types: | |
| - opened | |
| - synchronize | |
| concurrency: | |
| group: pull-request-page | |
| cancel-in-progress: false | |
| 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 | |
| with: | |
| ref: ${{github.event.pull_request.head.ref}} | |
| repository: ${{github.event.pull_request.head.repo.full_name}} | |
| - name: Determine the correct test server | |
| id: test-server | |
| run: echo "server=`./.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 | |
| 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@v5 | |
| with: | |
| node-version: 20 | |
| - name: Run npm ci | |
| run: npm ci | |
| - name: Build the app | |
| run: | | |
| # This set the editor's datasource to the relevant test server | |
| sed -i "s#develop.opencast.org#$SERVER#g" public/editor-settings.toml | |
| npm run build | |
| env: | |
| SERVER: ${{needs.detect-repo-owner.outputs.server}} | |
| PUBLIC_URL: ${{ steps.build-path.outputs.build }} | |
| - name: Prepare git | |
| run: | | |
| git config --global user.name "Editor 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@v2 | |
| 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 }}/opencast-editor-test.git" editor-test | |
| - name: Store build in the clone | |
| env: | |
| DEPLOY_PATH: editor-test/${{ steps.build-path.outputs.build }} | |
| run: | | |
| mkdir -p ${DEPLOY_PATH} | |
| cp -rv build/* ${DEPLOY_PATH} | |
| - name: Cleanup test repository | |
| working-directory: editor-test | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| wget https://raw.githubusercontent.com/${{ github.repository_owner }}/opencast-editor-test/main/.github/scripts/cleanup-deployments.sh | |
| bash cleanup-deployments.sh ${{ github.repository_owner }}/opencast-editor | |
| rm -f cleanup-deployments.sh | |
| git add . | |
| - name: Generate index.html | |
| working-directory: editor-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: editor-test | |
| run: | | |
| git add . | |
| git commit --amend -m "Build ${{ steps.build-path.outputs.build }}" | |
| - name: Push updates | |
| working-directory: editor-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.editor.opencast.org/${{ steps.build-path.outputs.build }} | |
| ](https://test.editor.opencast.org/${{ steps.build-path.outputs.build }}). | |
| It might take a few minutes for it to become available. | |
| #This is currently defunct, but kept around in case we run into issues in the future | |
| # where this check might be handy, cf spammers filing PRs or something. | |
| # Previously we checked is_team_member prior to doing anything else above | |
| check-member: | |
| name: Check organization membership | |
| if: github.repository_owner == 'opencast' | |
| runs-on: ubuntu-latest | |
| # Map a step output to a job output | |
| outputs: | |
| is_team_member: ${{ steps.is_developer.outputs.permitted == 'true' || steps.is_committer.outputs.permitted == 'true' }} | |
| steps: | |
| - name: Check if user is Opencast developer | |
| id: is_developer | |
| if: ${{ github.event.pull_request.head.repo.full_name != 'opencast/opencast-editor' }} | |
| uses: TheModdingInquisition/actions-team-membership@v1.0 | |
| with: | |
| team: developers | |
| # Personal Access Token with the `read:org` permission | |
| token: ${{ secrets.ORGANIZATION_MEMBER_SECRET }} | |
| exit: false | |
| - name: Check if user is Opencast committer | |
| id: is_committer | |
| if: ${{ github.event.pull_request.head.repo.full_name != 'opencast/opencast-editor' }} | |
| uses: TheModdingInquisition/actions-team-membership@v1.0 | |
| with: | |
| team: committers | |
| # Personal Access Token with the `read:org` permission | |
| token: ${{ secrets.ORGANIZATION_MEMBER_SECRET }} | |
| exit: false | |
| 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@v5 | |
| - name: Get changed locale files | |
| uses: dorny/paths-filter@v3 | |
| id: filter_locales | |
| with: | |
| filters: | # !(pattern) matches anything but pattern | |
| locales: | |
| - 'src/i18n/locales/!(en-US)*.json' | |
| - name: Check for changes in translations | |
| if: steps.filter_locales.outputs.locales == true | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| core.setFailed('You should not alter translations outside of Crowdin.') |