generate logs.json #3583
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: interop | |
on: | |
push: | |
branches: ["s3-setup"] | |
jobs: | |
backblaze: | |
runs-on: ubuntu-latest | |
# These permissions are needed to interact with GitHub's OIDC Token endpoint. | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- run: echo "foobar" > result.json | |
- name: Install b2 cli | |
uses: sylwit/[email protected] | |
env: | |
B2_APPLICATION_KEY_ID: ${{ secrets.BACKBLAZE_KEY_ID }} | |
B2_APPLICATION_KEY: ${{ secrets.BACKBLAZE_APPLICATION_KEY }} | |
- name: remove old logs | |
run: | | |
threshold_time=$((($(date +%s) * 1000) - (${{ vars.LOG_RETENTION_DAYS }} * 24 * 60 * 60 * 1000))) | |
old_files=$(b2 ls --json ${{ vars.BACKBLAZE_BUCKET}} | jq -r ".[] | select(.uploadTimestamp < $threshold_time)") | |
echo "Deleting files:" | |
echo $old_files | jq ".fileName" | |
# Now delete them | |
echo $old_files | jq -r ".fileName" | while read -r filename; do | |
dir_name="${filename%%/*}" | |
echo "Deleting $dir_name" | |
# see https://github.com/Backblaze/B2_Command_Line_Tool/issues/495#issuecomment-413932585 | |
mkdir empty # create an empty directory | |
b2 sync --delete --allowEmptySource empty b2://${{ vars.BACKBLAZE_BUCKET }}/"$dir_name" | |
rmdir empty | |
done | |
- name: generate logs.json and upload it | |
run: | | |
b2 ls --json quic-interop-runner | jq '[sort_by(.uploadTimestamp) | .[] | select(.fileName | contains("/")) | .fileName | split("/")[0] | select(. != null)]' > logs.json | |
b2 sync ./logs.json b2://${{ vars.BACKBLAZE_BUCKET }} | |