问题描述
我想建立一个GitHub动作工作流程:
- 向另一个站点(GitHub外部)发出API请求,该站点返回JSON。
- 将该JSON添加(提交)到我的仓库中
我有一个如下所示的操作。它似乎正常运行,并且日志甚至输出该文件已保存。但是,该文件永远不会出现在我的仓库中。
我以前从未设置过动作,所以对于它们周围的一些术语我也是新手。
关于如何执行此操作或工作的任何提示或想法,或替代方法?
name: Refresh Feed
on: [push]
jobs:
refresh-feed:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Fetch API Data
uses: JamesIves/fetch-api-data-action@1.0.15
with:
ENDPOINT: https://www.loc.gov/maps/?fa=location:cyprus&fo=json&at=results
RETRY: true
解决方法
我的意思是,从存储库的自述文件来看,您似乎只需要使用github令牌运行此操作即可。我只是运行了Fetch API Data动作,并且能够看到在动作后的步骤中运行ls创建的新目录。
然后,您需要创建一个秘密并添加环境ACCESS_TOKEN
要运行的动作
name: Refresh Feed
on:
schedule:
- cron: 10 15 * * 0-6
jobs:
refresh-feed:
runs-on: ubuntu-latest
steps:
- name: Checkout ?️
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Fetch API Data ?
uses: JamesIves/fetch-api-data-action@releases/v1
with:
ENDPOINT: https://www.loc.gov/maps/?fa=location:cyprus&fo=json&at=results
retry: true
- name: Build and Deploy ?
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: master # Pushes the updates to the master branch.
FOLDER: fetch-api-data-action # The location of the data.json file saved by the Fetch API Data action.
TARGET_FOLDER: data # Saves the data into the 'data' directory on the master branch.