Update Exchange Rate #172
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: Update Exchange Rate | |
on: | |
schedule: | |
- cron: '30 1 * * *' # 每天UTC时间01:30,相当于北京时间09:30 | |
workflow_dispatch: # 手动触发 | |
permissions: | |
contents: write | |
env: | |
FORCE_JAVASCRIPT_ACTIONS_TO_NODE20: true # 强制使用 Node20 | |
jobs: | |
update-exchange-rate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 # 使用 v3 | |
- name: Install dependencies | |
run: | | |
python -m pip install requests | |
- name: Fetch exchange rate from Alpha Vantage | |
env: | |
ALPHA_VANTAGE_API_KEY: ${{ secrets.ALPHA_VANTAGE_API_KEY }} | |
run: | | |
python update_exchange_rate.py | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add exchange_rate.json | |
git diff-index --quiet HEAD || git commit -m "Update exchange rate" | |
git push origin HEAD:main |