-
Notifications
You must be signed in to change notification settings - Fork 18
42 lines (36 loc) · 1.44 KB
/
pull-request-closed.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
name: Pull Request - Clean Up
on:
pull_request_target:
types: [closed]
env:
GH_TOKEN: ${{ github.token }}
jobs:
remove-deployment:
runs-on: ubuntu-latest
steps:
- name: Checkout repository files
uses: actions/checkout@v4
- name: Stop container and remove folder
uses: appleboy/ssh-action@master
continue-on-error: true
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /var/docker/pr-${{ github.event.number }}
docker compose down
cd ..
rm -r pr-${{ github.event.number }}
- name: Delete Docker tag
continue-on-error: true
run: |
token=$(curl -s -L 'https://hub.docker.com/v2/users/login' -H 'Content-Type: application/json' -d '{ "username": "${{ secrets.DOCKER_USERNAME }}", "password": "${{ secrets.DOCKER_PASSWORD }}"}')
token=${token#*\"token\":\"}
token=${token%%\"*}
curl -s -L -X DELETE "https://hub.docker.com/v2/namespaces/aamdigital/repositories/ndb-server/tags/pr-${{ github.event.number }}" -H "Authorization: Bearer $token"
- name: Delete github caches for current branch
run: |
gh cache list -L 200 --ref "refs/pull/${{ github.event.number }}/merge" --json id --jq '.[] | .id' | while read -r id; do
gh cache delete "$id"
done