-
Notifications
You must be signed in to change notification settings - Fork 37
86 lines (82 loc) · 2.57 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Package Clean Up
on:
pull_request:
types: [closed]
jobs:
preview-clean-up:
name: "Clean Up Preview deployments"
runs-on: "ubuntu-latest"
permissions:
contents: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: preview
- name: Setup Git
run: |
git config --global user.name "xLabs Playground CI"
git config --global user.email "devops@xlabs-playground.xyz"
- name: Set Version
run: echo "_BRANCH_NAME_SHA=$(echo ${{ github.event.pull_request.head.ref }} | sha256sum | cut -c -10)" >> "${GITHUB_ENV}"
- name: Unpublish and remove preview artifacts
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
cd preview
shopt -s extglob
export INPUT=$(gh pr list --json headRefName --jq '.[].headRefName')
export OUTPUT=""
for BRANCH in ${INPUT}; do
HASH=$(echo ${BRANCH} | sha256sum | cut -c -10)
if [ -n "${OUTPUT}" ]; then
OUTPUT="${OUTPUT}|${HASH}"
else
OUTPUT="${HASH}"
fi
done
rm -rf !(${OUTPUT})
git add .
git commit -m"Remove preview artifacts"
git push
testnet-clean-up:
name: "Clean Up Testnet deployments"
runs-on: "ubuntu-latest"
permissions:
contents: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: testnet
- name: Setup Git
run: |
git config --global user.name "xLabs Playground CI"
git config --global user.email "devops@xlabs-playground.xyz"
- name: Compute Version
run: |
echo "_BRANCH_NAME_SHA=$(echo ${{ github.event.pull_request.head.ref }} | sha256sum | cut -c -10)" >> "${GITHUB_ENV}"
- name: Unpublish and remove testnet artifacts
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
cd testnet
shopt -s extglob
export INPUT=$(gh pr list --json headRefName --jq '.[].headRefName')
export OUTPUT=""
for BRANCH in ${INPUT}; do
HASH=$(echo ${BRANCH} | sha256sum | cut -c -10)
if [ -n "${OUTPUT}" ]; then
OUTPUT="${OUTPUT}|${HASH}"
else
OUTPUT="${HASH}"
fi
done
rm -rf !(${OUTPUT})
git add .
git commit -m"Remove testnet artifacts"
git push