-
Notifications
You must be signed in to change notification settings - Fork 5
60 lines (49 loc) · 1.68 KB
/
pack-results.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
name: Pack Survey Results
on:
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
inputs:
date:
description: 'Date of the survey results to pack (e.g. 2024-01-01)'
required: true
jobs:
publish:
runs-on: ubuntu-latest
name: Pack Survey Results
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install rclone
shell: bash
run: |
curl -sL https://rclone.org/install.sh | sudo bash
rclone config create --no-obscure openttd s3 \
provider Cloudflare \
access_key_id ${{ secrets.R2_SURVEY_ACCESS_KEY_ID }} \
secret_access_key ${{ secrets.R2_SURVEY_SECRET_ACCESS_KEY }} \
endpoint ${{ secrets.R2_SURVEY_ENDPOINT }} \
acl private \
no_check_bucket true
- name: Download, pack, and upload survey results
shell: bash
run: |
date="${{ inputs.date }}"
if [ -z "$date" ]; then
date=$(date -d "yesterday" +%Y-%m-%d)
fi
year=$(date -d "${date}" +%Y)
month=$(date -d "${date}" +%m)
echo "Packing all results for ${date}"
echo "::group::Download survey results"
rclone copy -v openttd:survey-prod/${date} ${date}
echo "::endgroup::"
echo "::group::Pack survey results"
tar --xz -cvf openttd-survey-pack.${date}.tar.xz ${date}
echo "::endgroup::"
echo "::group::Upload survey result pack"
rclone copy -v openttd-survey-pack.${date}.tar.xz openttd:survey-packed-prod/${year}/${month}
echo "::endgroup::"
echo "::group::Remove survey results"
rclone delete -v openttd:survey-prod/${date}
echo "::endgroup::"