Pack Survey Results #367
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: 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::" |