-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (39 loc) · 1.74 KB
/
website_cleanup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 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