whisper-frontend/.gitea/workflows/cleanup-branch.yaml
Andreas Svanberg 2716fc9a77 Automatically deploy pull requests for testing (#8)
When a pull request is opened, will deploy that branch to `<reponame>-<branchname>.branch.dsv.su.se` with branch name having `/` replaced with `-` and all characters that do not match `[a-z0-9-]` are removed.
Co-authored-by: Andreas Svanberg <andreass@dsv.su.se>
Co-committed-by: Andreas Svanberg <andreass@dsv.su.se>
2024-07-08 14:29:40 +02:00

22 lines
815 B
YAML

name: Clean up branch.dsv.su.se
on:
pull_request:
types:
- closed
jobs:
Cleanup-branch:
runs-on: ubuntu-latest
steps:
- name: Generate mangled vhost name
id: mangled-name
run: |
MANGLED_BRANCH_NAME="$(echo ${{ gitea.headref}} | sed -r -e 's%/%-%g' -e 's/[^0-9a-z\-]//g')"
echo $MANGLED_BRANCH_NAME
echo "MANGLED_NAME=$MANGLED_BRANCH_NAME" >> "$GITHUB_OUTPUT"
- name: Set up SSH key
run: |
echo "${{ secrets.BRANCH_CLEANUP_KEY }}" >> ssh_key
chmod 0600 ssh_key
- name: Execute clean up script
run: echo "${{ gitea.serverurl }}/${{ gitea.repository }}.git ${{ gitea.headref }} ${{ steps.mangled-name.outputs.MANGLED_NAME }}" | ssh -o StrictHostKeyChecking=accept-new -i ssh_key branch.dsv.su.se