Skip to content

Commit 63e2bab

Browse files
generate logs.json
1 parent 3b84b37 commit 63e2bab

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

.github/workflows/interop.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ jobs:
1010
permissions:
1111
id-token: write
1212
contents: read
13-
env:
14-
BUCKET: "quic-interop-runner"
15-
RETENTION_DAYS: "3"
1613
steps:
1714
- uses: actions/checkout@v3
1815
- uses: actions/setup-python@v4
@@ -24,19 +21,27 @@ jobs:
2421
env:
2522
B2_APPLICATION_KEY_ID: ${{ secrets.BACKBLAZE_KEY_ID }}
2623
B2_APPLICATION_KEY: ${{ secrets.BACKBLAZE_APPLICATION_KEY }}
27-
- name: upload a file
24+
- name: remove old logs
2825
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)")
3128
echo "Deleting files:"
3229
echo $old_files | jq ".fileName"
3330
# Now delete them
3431
echo $old_files | jq -r ".fileName" | while read -r filename; do
3532
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
4141
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+
4247

0 commit comments

Comments
 (0)