10
10
permissions :
11
11
id-token : write
12
12
contents : read
13
- env :
14
- BUCKET : " quic-interop-runner"
15
- RETENTION_DAYS : " 3"
16
13
steps :
17
14
- uses : actions/checkout@v3
18
15
- uses : actions/setup-python@v4
@@ -24,19 +21,27 @@ jobs:
24
21
env :
25
22
B2_APPLICATION_KEY_ID : ${{ secrets.BACKBLAZE_KEY_ID }}
26
23
B2_APPLICATION_KEY : ${{ secrets.BACKBLAZE_APPLICATION_KEY }}
27
- - name : upload a file
24
+ - name : remove old logs
28
25
run : |
29
- threshold_time=$((($(date +%s) * 1000) - (${{ env.RETENTION_DAYS }} * 24 * 60 * 60 * 1000)))
30
- old_files=$(b2 ls --json ${{ env.BUCKET }} | jq -r ".[] | select(.uploadTimestamp > $threshold_time)")
26
+ threshold_time=$((($(date +%s) * 1000) - (${{ vars.LOG_RETENTION_DAYS }} * 24 * 60 * 60 * 1000)))
27
+ old_files=$(b2 ls --json ${{ vars.BACKBLAZE_BUCKET }} | jq -r ".[] | select(.uploadTimestamp < $threshold_time)")
31
28
echo "Deleting files:"
32
29
echo $old_files | jq ".fileName"
33
30
# Now delete them
34
31
echo $old_files | jq -r ".fileName" | while read -r filename; do
35
32
dir_name="${filename%%/*}"
36
- echo "Deleting $dir_name"
37
- # see https://github.com/Backblaze/B2_Command_Line_Tool/issues/495#issuecomment-413932585
38
- mkdir empty # create an empty directory
39
- b2 sync --delete --allowEmptySource empty b2://${{ env.BUCKET }}/"$dir_name"
40
- rmdir empty
33
+ # skip files, we only care about directories
34
+ if [[ "$dir_name" != "." ]]; then
35
+ echo "Deleting $dir_name"
36
+ # see https://github.com/Backblaze/B2_Command_Line_Tool/issues/495#issuecomment-413932585
37
+ mkdir empty # create an empty directory
38
+ b2 sync --delete --allowEmptySource empty b2://${{ vars.BACKBLAZE_BUCKET }}/"$dir_name"
39
+ rmdir empty
40
+ fi
41
41
done
42
+ - name : generate logs.json and upload it
43
+ run : |
44
+ b2 ls --json quic-interop-runner | jq '[sort_by(.uploadTimestamp) | .[] | select(.fileName | contains("/")) | .fileName | split("/")[0] | select(. != null)]' > logs.json
45
+ b2 upload-file ${{ vars.BACKBLAZE_BUCKET }} logs.json logs.json
46
+
42
47
0 commit comments