-
Notifications
You must be signed in to change notification settings - Fork 636
138 lines (134 loc) · 4.93 KB
/
clear_cache.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Clean up caches created by BinDiff job
name: Dynamo-PostBinDiffProcess
on:
workflow_run:
workflows: [Dynamo-BinDiff]
types:
- completed
jobs:
fetch-PR-Data:
runs-on: ubuntu-latest
steps:
- name: Download PR Data
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{github.event.workflow_run.id }}
name: pr
path: pr/
- name: Check Artifact
run: ls -R
- name: Extract Data to Output
id: extract
run: |
cat pr/NR
echo "PRNumber=`cat pr/NR`" >> "$GITHUB_OUTPUT"
echo "WFNumber=`cat pr/WN`" >> "$GITHUB_OUTPUT"
echo "Diff1=`cat pr/Diff1`" >> "$GITHUB_OUTPUT"
echo "Diff2=`cat pr/Diff2`" >> "$GITHUB_OUTPUT"
echo "TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S`" >> "$GITHUB_OUTPUT"
outputs:
PRNumber: ${{ steps.extract.outputs.PRNumber }}
WFNumber: ${{ steps.extract.outputs.WFNumber }}
Diff1: ${{ steps.extract.outputs.Diff1 }}
Diff2: ${{ steps.extract.outputs.Diff2 }}
TIMESTAMP: ${{ steps.extract.outputs.TIMESTAMP }}
diff-cache-cleanup-pr:
runs-on: ubuntu-latest
needs: [fetch-PR-Data]
if: github.event.workflow_run.event == 'pull_request'
steps:
- name: Cleanup Caches
run: |
gh extension install actions/gh-actions-cache
PRNUM=${{ needs.fetch-PR-Data.outputs.PRNumber }}
REPO=${{ github.repository }}
BRANCH="refs/pull/$PRNUM/merge"
echo "Fetching list of cache key"
echo $REPO
echo $BRANCH
echo $PRNUM
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
echo "Deleting: $cacheKey"
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff-cache-cleanup-push:
runs-on: ubuntu-latest
needs: [fetch-PR-Data]
if: github.event.workflow_run.event == 'push'
steps:
- name: Cleanup Caches
run: |
gh extension install actions/gh-actions-cache
WNNUM=${{ needs.fetch-PR-Data.outputs.WFNumber }}
echo $WNNUM
REPO=${{ github.repository }}
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
echo "Deleting: $WNNUM-cache-net60Win-current"
gh actions-cache delete $WNNUM-cache-net60Win-current -R $REPO --confirm
echo "Deleting: $WNNUM-cache-net60Win-master"
gh actions-cache delete $WNNUM-cache-net60Win-master -R $REPO --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comments-pr-workflow:
runs-on: ubuntu-latest
needs: [fetch-PR-Data]
if: github.event.workflow_run.event == 'pull_request'
steps:
- name: Download PR Data
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{github.event.workflow_run.id }}
name: pr
path: pr/
- name: Check Artifact
run: ls -R
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ needs.fetch-PR-Data.outputs.PRNumber }}
comment-author: 'github-actions[bot]'
body-includes: Files Added/Deleted
direction: last
- name: Create comment
if: |
steps.fc.outputs.comment-id == '' &&
(needs.fetch-PR-Data.outputs.Diff1 != '' || needs.fetch-PR-Data.outputs.Diff2 != '')
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ needs.fetch-PR-Data.outputs.PRNumber }}
body: |
${{ needs.fetch-PR-Data.outputs.Diff1 }}
${{ needs.fetch-PR-Data.outputs.Diff2 }}
- name: Update comment
if: |
steps.fc.outputs.comment-id != '' &&
(needs.fetch-PR-Data.outputs.Diff1 != '' || needs.fetch-PR-Data.outputs.Diff2 != '')
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
${{ needs.fetch-PR-Data.outputs.Diff1 }}
${{ needs.fetch-PR-Data.outputs.Diff2 }}
(Updated: ${{ needs.fetch-PR-Data.outputs.TIMESTAMP }})
- name: Update comment resolved
if: |
steps.fc.outputs.comment-id != '' &&
(needs.fetch-PR-Data.outputs.Diff1 == '' && needs.fetch-PR-Data.outputs.Diff2 == '')
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
":white_check_mark: **Bin-Diff Issue Resolved.**"
(Updated: ${{ needs.fetch-PR-Data.outputs.TIMESTAMP }})