Run Python script and log output #8
This file contains hidden or 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: Run Python script and log output | |
on: | |
schedule: | |
- cron: "0 9 01 * *" # At 09:00 on day-of-month 1. | |
push: | |
branches: | |
- main | |
jobs: | |
run_script: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run Python script | |
env: | |
MY_SECRET: ${{ secrets.MY_GITHUB_TOKEN }} | |
run: | | |
python main.py | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add open-source.txt | |
git commit -m "Update open-source.txt log" | |
git push origin main |