Skip to content

backupGDrive

backupGDrive #140

Workflow file for this run

on:
push:
branches: [master]
schedule:
- cron: '0 4 * * *'
name: backupGDrive
jobs:
backup:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_AUTHENTICATION_BASE64: ${{ secrets.GOOGLE_AUTHENTICATION_BASE64 }}
GOOGLE_AUTHENTICATION_CREDENTIALS: ${{ secrets.GOOGLE_AUTHENTICATION_CREDENTIALS }}
GOOGLE_SHEET_CONTATTI: ${{ secrets.GOOGLE_SHEET_CONTATTI }}
QFIELD_CLOUD_PASSWORD: ${{ secrets.QFIELD_CLOUD_PASSWORD }}
QFIELD_CLOUD_USERNAME: ${{ secrets.QFIELD_CLOUD_USERNAME }}
QFIELD_CLOUD_PROJECTNAME: ${{ secrets.QFIELD_CLOUD_PROJECTNAME }}
steps:
- name: "Check out repository"
uses: actions/checkout@v4
- name: Install dependencies on Linux
if: runner.os == 'Linux'
run: sudo apt-get update; sudo apt-get -y install libcurl4-openssl-dev libudunits2-dev libproj-dev libgdal-dev libgeos-dev
- name: "Setup R"
uses: r-lib/actions/setup-r@v2
- name: Install R Dependencies
uses: r-lib/actions/setup-renv@v2
- name: Import data
run: Rscript -e 'source("scripts/start_scripts/importFromQfieldCloud.R")'
- name: Set Google Application Credentials
run: echo "$GOOGLE_AUTHENTICATION_CREDENTIALS" > /tmp/google_service_account.json
- name: Backup file
run: Rscript -e 'source("scripts/backup.R")'
- name: Generate Dynamic Filename
run: |
# Generate the dynamic filename based on the current date and time
TIMESTAMP=$(date +'%Y-%m-%d-%H-%M-%S')
FILENAME="auto-$TIMESTAMP.zip"
# Set the environment variable
echo "FILENAME=$FILENAME" >> $GITHUB_ENV
- name: Upload the file to Google Drive
uses: willo32/google-drive-upload-action@v1
with:
target: "/tmp/projdir.zip"
credentials: ${{ secrets.GOOGLE_AUTHENTICATION_BASE64 }}
parent_folder_id: ${{ secrets.BK_FOLDER_ID }}
name: ${{ env.FILENAME }}