-
Notifications
You must be signed in to change notification settings - Fork 986
66 lines (59 loc) · 2.41 KB
/
cancel_outdate_runs.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
name: cancel_outdate_runs
on:
pull_request:
branches:
- main
- release**
jobs:
cancel-outdate-runs:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with :
fetch-depth: 1
- name: mount jfs dir
timeout-minutes: 3
run: |
sudo mkdir -p /root/.juicefs
sudo wget -q s.juicefs.com/static/Linux/mount -O /root/.juicefs/jfsmount
sudo chmod +x /root/.juicefs/jfsmount
sudo curl -s -L https://juicefs.com/static/juicefs -o /usr/local/bin/juicefs && sudo chmod +x /usr/local/bin/juicefs
sudo juicefs auth ci-coverage --access-key ${{ secrets.CI_COVERAGE_AWS_AK }} --secret-key ${{ secrets.CI_COVERAGE_AWS_SK }} --token ${{ secrets.CI_COVERAGE_AWS_TOKEN }} --encrypt-keys
sudo juicefs mount ci-coverage --subdir juicefs/cancel-outdate-runs /jfs --allow-other
- name: Get previous head_sha
timeout-minutes: 1
run: |
echo get previous head sha from /jfs/${{ github.event.pull_request.number }}/head_sha
previous_head_sha=/jfs/${{ github.event.pull_request.number }}/head_sha
if [ ! -f ${previous_head_sha} ]; then
echo "no previous head sha found"
exit 0
else
previous_head_sha=$(cat ${previous_head_sha})
echo "previous head sha is ${previous_head_sha}"
echo "previous_head_sha=${previous_head_sha}" >> $GITHUB_ENV
fi
- name: Save head_sha
timeout-minutes: 1
run: |
mkdir -p /jfs/${{ github.event.pull_request.number }}
echo ${{ github.event.pull_request.head.sha }} | tee /jfs/${{ github.event.pull_request.number }}/head_sha
echo save head sha to /jfs/${{ github.event.pull_request.number }}/head_sha
- name : Cancel Outdate Runs
uses: ./.github/actions/cancel-outdate-runs
with:
per_page: 8
page: 1
head_sha: ${{ env.previous_head_sha }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Wait Runs Cancelled
run: |
sleep 10s
- name : Cancel Outdate Runs
uses: ./.github/actions/cancel-outdate-runs
with:
per_page: 8
page: 1
head_sha: ${{ env.previous_head_sha }}
github_token: ${{ secrets.GITHUB_TOKEN }}