[英]Python code to execute a SQL script and create a CSV file with a customised name
[英]Github action to execute a Python script that create a file, then commit and push this file
我的 repo 包含一個main.py
,它生成一個 html map 並將結果保存在 csv 中。我希望操作:
name: refresh map
on:
schedule:
- cron: "30 11 * * *" #runs at 11:30 UTC everyday
jobs:
getdataandrefreshmap:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v3 # checkout the repository content to github runner.
- name: setup python
uses: actions/setup-python@v4
with:
python-version: 3.8 #install the python needed
- name: Install dependencies
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: execute py script
uses: actions/checkout@v3
run: |
python main.py
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "crongenerated"
git push
當我包含第二次uses: actions/checkout@v3
和 git 命令。
在此先感謝您的幫助
如果你想運行一個腳本,那么你不需要額外的檢查步驟。 使用工作流的步驟和直接執行shell腳本的步驟是有區別的。 您可以在此處閱讀更多相關信息。
在你的配置文件中,你在最后一步混合了兩者。 您不需要額外的結帳步驟,因為第一步中的回購仍處於結帳狀態。 所以你可以只使用以下工作流程:
name: refresh map
on:
schedule:
- cron: "30 11 * * *" #runs at 11:30 UTC everyday
jobs:
getdataandrefreshmap:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v3 # checkout the repository content to github runner.
- name: setup python
uses: actions/setup-python@v4
with:
python-version: 3.8 #install the python needed
- name: Install dependencies
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: execute py script
run: |
python main.py
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "crongenerated"
git push
我用一個虛擬倉庫測試了它,一切正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.