使用Github Actions使API获得请求并保存数据以回购

问题描述

我想建立一个GitHub动作工作流程:

  1. 向另一个站点(GitHub外部)发出API请求,该站点返回JSON。
  2. 将该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创建的新目录。

How to get github token

enter image description here

然后,您需要创建一个秘密并添加环境ACCESS_TOKEN

How to create secrets in repo

要运行的动作

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.

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...