From c27f4aff45ea6f8d1b971ebeb9d8edce59eccde2 Mon Sep 17 00:00:00 2001 From: Suheb <39208279+saubyk@users.noreply.github.com> Date: Sat, 20 Sep 2025 17:55:31 -0700 Subject: [PATCH] Create traffic-exporter.yml automated metrics extraction --- .github/workflows/traffic-exporter.yml | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/traffic-exporter.yml diff --git a/.github/workflows/traffic-exporter.yml b/.github/workflows/traffic-exporter.yml new file mode 100644 index 00000000..06e9db07 --- /dev/null +++ b/.github/workflows/traffic-exporter.yml @@ -0,0 +1,37 @@ +name: Export Repo Traffic to Google Sheets + +on: + schedule: + # Runs at 02:00 UTC every day + - cron: '0 2 * * *' + workflow_dispatch: # Allows you to run this workflow manually from the Actions tab + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install gspread oauth2client requests + + - name: Write Google credentials to a file + id: write_creds + uses: timheuer/base64-to-file@v1.2 + with: + fileName: 'google-credentials.json' + encodedString: ${{ secrets.GOOGLE_SHEETS_CREDENTIALS }} + + - name: Run the Python script + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + GOOGLE_SHEETS_CREDENTIALS: ${{ steps.write_creds.outputs.filePath }} + run: python export_traffic.py