-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (43 loc) · 1.79 KB
/
CLEAN_APIUtils.yml
File metadata and controls
54 lines (43 loc) · 1.79 KB
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
52
53
54
# Workflow to clean out the directory where files from a deleted "APIUtils" branch were deployed on the CI server
name: Cleanup Dead Branch - APIUtils
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_DIR: ${{ vars.API_BASE_PATH }}/${{ github.event.repository.name }}/${{ github.event.ref }}
DEPLOY_URL: ${{ vars.OGD_STAGING_HOST }}/${{ vars.API_BASE_URL }}/${{ github.event.repository.name }}/${{ github.event.ref }}/app.wsgi
jobs:
branch_delete:
name: Dead Branch 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: Connect to VPN
uses: opengamedata/actions-openconnect-vpn@v1.1
with:
username: ${{ secrets.VPN_USER }}
password: ${{ secrets.VPN_PASS }}
endpoint: "soe.vpn.wisc.edu"
- name: Setup Access Key
run: |
mkdir -p ~/.ssh
echo '${{secrets.CLEAN_KEY}}' >> ./key.txt
chmod 600 ./key.txt
# 4. Cleanup & complete
- name: Remove branch folder
run: ssh -o StrictHostKeyChecking=no -T -i ./key.txt ${{ secrets.CLEAN_USER }}@${{ env.DEPLOY_HOST }} "rm -r ${{ env.DEPLOY_DIR }}"
- name: Announce cleanup
run: echo "Removed branch deploy at ${{ env.DEPLOY_URL }}"
- name: Upload logs as artifacts
uses: actions/upload-artifact@v4
with:
name: "cleanup-log"
path: ./*.log