|
| 1 | +name: Remove Pull Request Page |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - closed |
| 7 | + |
| 8 | +jobs: |
| 9 | + delete_directory: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: prepare git |
| 13 | + run: | |
| 14 | + git config --global user.name "Admin Interface Deployment Bot" |
| 15 | + git config --global user.email "cloud@opencast.org" |
| 16 | +
|
| 17 | + - name: prepare GitHub SSH key |
| 18 | + env: |
| 19 | + DEPLOY_KEY: ${{ secrets.DEPLOY_KEY_TEST }} |
| 20 | + run: | |
| 21 | + install -dm 700 ~/.ssh/ |
| 22 | + echo "${DEPLOY_KEY}" > ~/.ssh/id_ed25519 |
| 23 | + chmod 600 ~/.ssh/id_ed25519 |
| 24 | + ssh-keyscan github.com >> ~/.ssh/known_hosts |
| 25 | +
|
| 26 | + - name: clone repository |
| 27 | + run: | |
| 28 | + git clone "git@github.com:opencast/opencast-admin-interface-test.git" admin-interface-test |
| 29 | +
|
| 30 | + - name: switch to gh-pages branch |
| 31 | + working-directory: admin-interface-test |
| 32 | + run: | |
| 33 | + git checkout gh-pages |
| 34 | +
|
| 35 | + - name: delete build |
| 36 | + working-directory: admin-interface-test |
| 37 | + run: | |
| 38 | + if [ -d "${PR_NUMBER}" ]; then |
| 39 | + rm -rf "${PR_NUMBER}" |
| 40 | + echo "Directory ${PR_NUMBER} deleted successfully." |
| 41 | + else |
| 42 | + echo "Directory ${PR_NUMBER} does not exist. Skipping deletion." |
| 43 | + fi |
| 44 | +
|
| 45 | + - name: clean index.html |
| 46 | + working-directory: admin-interface-test |
| 47 | + run: | |
| 48 | + echo '<html><body><ul>' > index.html |
| 49 | + find . -maxdepth 2 -name '*_*' -type d \ |
| 50 | + | sort -r \ |
| 51 | + | sed 's/^\(.*\)$/<li><a href=\1>\1<\/a><\/li>/' >> index.html |
| 52 | + echo '</ul></body></html>' >> index.html |
| 53 | +
|
| 54 | + - name: commit new version |
| 55 | + working-directory: admin-interface-test |
| 56 | + run: | |
| 57 | + git add . |
| 58 | + git commit -m "Remove deployment ${PR_NUMBER} due to PR closure" |
| 59 | +
|
| 60 | + - name: push updates |
| 61 | + working-directory: admin-interface-test |
| 62 | + run: | |
| 63 | + git push origin gh-pages |
0 commit comments