使用 Github 操作进行 API 获取请求并将数据保存到 repo
Use Github Actions to make API get request and save data to repo
我想设置一个 GitHub 操作工作流:
- 向另一个站点(GitHub 之外)发出 API 请求,returns 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
我的意思是从 repo 的自述文件来看,您似乎只需要 运行 使用 github 令牌执行此操作。我只是 运行 获取 API 数据操作,并且能够看到通过 运行 在操作后的步骤中使用 ls 创建的新目录。
然后你需要创建一个秘密并添加 env 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.
我想设置一个 GitHub 操作工作流:
- 向另一个站点(GitHub 之外)发出 API 请求,returns 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
我的意思是从 repo 的自述文件来看,您似乎只需要 运行 使用 github 令牌执行此操作。我只是 运行 获取 API 数据操作,并且能够看到通过 运行 在操作后的步骤中使用 ls 创建的新目录。
然后你需要创建一个秘密并添加 env 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.