Skip to content

daily-notion-automation #640

daily-notion-automation

daily-notion-automation #640

name: daily-notion-automation
# run-name: ${{ github.actor }} is learning GitHub Actions
on:
schedule:
- cron: '30 5 * * *' # minute hour day month weekday https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07
push:
branches: [ "main" ]
jobs:
daily-notion-automation:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.11'
# Optional - x64 or x86 architecture, defaults to x64
architecture: 'x64'
- name: Configure Local Timezone
if: ${{ vars.LOCAL_TIMEZONE }}
uses: szenius/[email protected]
with:
timezoneLinux: ${{ vars.LOCAL_TIMEZONE }}
timezoneMacos: ${{ vars.LOCAL_TIMEZONE }}
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# - name: Test with pytest
# run: |
# pytest
# - id: 'auth'
# name: 'Authenticate to Google Cloud 2'
# uses: 'google-github-actions/[email protected]'
# with:
# workload_identity_provider: 'projects/836371454349/locations/global/workloadIdentityPools/githubactions/providers/github'
# service_account: '[email protected]'
- name: Installed package list
run: apt list --installed
- run: google-chrome --version
# - name: Remove Chrome
# run: sudo apt purge google-chrome-stable
# - name: Remove default Chromium
# run: sudo apt purge chromium-browser
# - name: Install a new Chromium
# run: sudo apt install -y chromium-browser
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/[email protected]'
with:
token_format: 'access_token'
workload_identity_provider: 'projects/973237400148/locations/global/workloadIdentityPools/githubactions/providers/github'
service_account: '[email protected]'
access_token_lifetime: '3600s' # optional
- id: 'access-secret'
run: |
curl https://secretmanager.googleapis.com/v1/projects/my-project/secrets/my-secret/versions/1:access \
--header "Authorization: Bearer ${{ steps.auth.outputs.access_token }}"
- name: Run code
run: python main.py
# - name: Set up Python
# uses: actions/checkout@v3
# with:
# python-version: 3.11
# - name: Test env vars for python
# run: python -c 'import os;print(os.environ)'
# env:
# ENV_SECRET: ${{ secrets.ENV_SECRET }}
# REPO_SECRET: ${{ secrets.REPO_SECRET }}