Deploy and Update Analytics #223
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: Deploy and Update Analytics | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 0 * * *' # Runs every day at midnight UTC | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
update-analytics: | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
environment: github-pages # Specify the environment here | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- run: npm install | |
- name: Run analytics update | |
run: npm run analytics | |
env: | |
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} | |
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} | |
GOOGLE_REFRESH_TOKEN: ${{ secrets.GOOGLE_REFRESH_TOKEN }} | |
PROPERTY_ID: ${{ secrets.PROPERTY_ID }} | |
deploy: | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
environment: github-pages # Specify the environment here | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'main' | |
fetch-depth: '0' | |
- name: Setup Node | |
uses: actions/[email protected] | |
with: | |
node-version: '20.x' | |
- name: Reconfigure git to use HTTP authentication | |
run: > | |
git config --global url."https://github.com/".insteadOf | |
ssh://[email protected]/ | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- run: npm ci | |
- run: npm run build | |
env: | |
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} | |
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} | |
GOOGLE_REFRESH_TOKEN: ${{ secrets.GOOGLE_REFRESH_TOKEN }} | |
PROPERTY_ID: ${{ secrets.PROPERTY_ID }} | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./_site | |
user_name: 'github-actions[bot]' | |
user_email: 'github-actions[bot]@users.noreply.github.com' |