OGD Website - Dead Branch Cleanup Script - 68-fix-weird-extra-space-in-game-cards #4
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
# Workflow to clean out the directory where a deleted branch's files were deployed by CI | |
name: OGD Website - Dead Branch Cleanup Script | |
run-name: ${{ format('{0} - {1}', github.workflow, github.event_name == 'delete' && github.event.ref || 'Manual Run') }} | |
on: | |
delete: # Trigger automatically when we do a deletion of a branch | |
workflow_dispatch: | |
env: | |
DEPLOY_HOST: ${{ vars.OGD_STAGING_HOST }} | |
DEPLOY_PATH: ${{ vars.WEB_PATH }}/${{ github.event.repository.name }}/${{ github.event.ref }} | |
DEPLOY_URL: ${{ vars.OGD_STAGING_HOST }}/${{ github.event.repository.name }}/${{ github.event.ref }} | |
jobs: | |
branch_delete: | |
name: Branch Deletion Cleanup | |
if: github.event.ref_type == 'branch' | |
runs-on: ubuntu-22.04 | |
# concurrency: | |
# group: ${{ github.repository }}-${{ github.ref }}-${{ github.workflow }} | |
# cancel-in-progress: false | |
steps: | |
# 1. Local checkout & config | |
# 2. Build | |
# 3. Remote config & clean | |
- name: Install OpenConnect | |
run: sudo apt-get -q update && sudo apt-get -q install openconnect | |
- name: Connect to VPN | |
run: echo ${{ secrets.VPN_PASS }} | sudo openconnect --protocol=gp -u ${{ secrets.VPN_USER}} --passwd-on-stdin soe.vpn.wisc.edu & | |
- name: Setup Access Key | |
run: | | |
mkdir -p ~/.ssh | |
echo '${{secrets.CLEAN_KEY}}' >> ./key.txt | |
chmod 600 ./key.txt | |
- name: Remove branch folder | |
run: ssh -o StrictHostKeyChecking=no -T -i ./key.txt ${{ secrets.CLEAN_USER }}@${{ env.DEPLOY_HOST }} "rm -r ${{ env.DEPLOY_PATH }}" | |
- name: Announce cleanup | |
run: echo "Removed branch deploy at ${{ env.DEPLOY_URL }}" | |
- name: Upload logs as artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
path: ./*.log | |