我正在使用此 GitHub 操作 https://github.com/JamesIves/fetch-api-data-action 来获取和保存 API 获取的数据:
这是我的 2 个操作的配置,一个是获取 API,然后构建和部署以保存从 API 获取的 .json
name: Refresh Feed
on: [push]
jobs:
refresh-feed:
runs-on: ubuntu-latest
steps:
- name: Fetch API Data ?
uses: JamesIves/fetch-api-data-action@releases/v1
with:
ENDPOINT: https://data
BRANCH: master # Pushes the updates to the master branch.
- name: Build and Deploy ?
uses: JamesIves/github-pages-deploy-action@4.1.1
with:
branch: master # The branch the action should deploy to.
folder: . # The folder the action should deploy.
由于此错误而失败
Run JamesIves/github-pages-deploy-action@4.1.1
9
10
GitHub Pages Deploy Action ?
11
12
? Getting Started Guide: https://github.com/marketplace/actions/deploy-to-github-pages
13
❓ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
14
? Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues
15
16
? Maintained by James Ives: https://jamesiv.es
17
? Support: https://github.com/sponsors/JamesIves
18
Checking configuration and starting deployment… ?
19
Deploying using Deploy Token… ?
20
Configuring git…
21
/usr/bin/git config user.name abcname
22
fatal: not in a git directory
23
Error: There was an error initializing the repository: The process '/usr/bin/git' failed with exit code 128 ❌
24
Deployment failed! ❌
我也尝试将“public”作为文件夹,但它也失败了,因为它说它不存在(不过我的仓库确实有那个文件夹)
答案 0 :(得分:1)
您使用的是该操作的旧版本。也许尝试转向 v4,它以不同的方式处理其中一些参数。如果您要回推到同一个存储库,您甚至不需要传递令牌。
除此之外,我认为有两件事需要检查:
您在第一个操作中引用了分支 main
,但在第二个操作中引用了 master
。这些是否指向同一个存储库?如果是这样,我认为分支名称会相同。
对于 v3 组件,ACCESS_TOKEN
的文档暗示您需要使用已存储在机密中的生成的个人访问令牌。这就是我在使用此操作时使用的内容,尽管我正在推送到不同的存储库,因此无论如何这是必须的。
不过我很久以前就迁移到了 v4。