Firebase 操作托管部署因 RequestError 失败(资源无法通过集成访问)
我正在尝试按照 https://firebase.google.com/docs/hosting/github-integration 开始自动推送我的代码以由 Firebase 托管。
我最终得到了一个如下所示的 Github Actions .yml 文件:
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on PR
'on': pull_request
jobs:
build_and_preview:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
runs-on: ubuntu-latest
environment: development
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: |
cd front
echo "$ENV_DEVELOPMENT" > .env.development
PWD=$(pwd)
npm install
sh -ac ". $PWD/.env.development; npm run build"
env:
ENV_DEVELOPMENT: ${{ secrets.ENV_DEVELOPMENT }}
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_MYPROJECT }}'
projectId: myproject
它运行良好,直到最后一个破折号,即
uses: FirebaseExtended/action-hosting-deploy@v0
.
我得到这个错误:
Run FirebaseExtended/action-hosting-deploy@v0
/home/runner/work/_actions/FirebaseExtended/action-hosting-deploy/v0/bin/action.min.js:3759
const error = new RequestError(message, status, ***
^
RequestError [HttpError]: Resource not accessible by integration
at /home/runner/work/_actions/FirebaseExtended/action-hosting-deploy/v0/bin/action.min.js:3759:31
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async createCheck (/home/runner/work/_actions/FirebaseExtended/action-hosting-deploy/v0/bin/action.min.js:5680:17)
at async run (/home/runner/work/_actions/FirebaseExtended/action-hosting-deploy/v0/bin/action.min.js:11435:14) ***
status: 403,
headers: ***
'access-control-allow-origin': '*',
...
'x-xss-protection': '0'
***,
request: ***
method: 'POST',
url: 'https://api.github.com/repos/mygithubuser/myproject/check-runs',
headers: ***
accept: 'application/vnd.github.v3+json',
'user-agent': 'octokit-core.js/3.2.4 Node.js/16.16.0 (linux; x64)',
authorization: 'token [REDACTED]',
'content-type': 'application/json; charset=utf-8'
***,
body: '***"name":"Deploy Preview","head_sha":"27df35c365f7289ac219329aeb45824ac2fde64a","status":"in_progress"***',
request: ***
agent: Agent ***
_events: [Object: null prototype] ***
free: [Function (anonymous)],
newListener: [Function: maybeEnableKeylog]
***,
_eventsCount: 2,
_maxListeners: undefined,
default port: 443,
...
maxCachedSessions: 100,
_sessionCache: ***
map: ***
'api.github.com:443:::::::::::::::::::::': [Buffer [Uint8Array]]
***,
list: [ 'api.github.com:443:::::::::::::::::::::' ]
***,
[Symbol(kCapture)]: false
***,
hook: [Function: bound bound register]
***
***,
documentation_url: 'https://docs.github.com/rest/reference/checks#create-a-check-run'
***
起初,我以为这是我的云服务工作者的权限错误,但如果我进入我的 console.cloud.google.com 到 IAM,我可以看到角色为“API Keys Viewer,Cloud Run”的 github-action查看器、Firebase 身份验证管理员和 Firebase 托管管理员'。为了看看是否有所作为,我还添加了所有者角色。
我可以尝试其他建议吗?
试试这个:确保为 GITHUB_TOKEN 启用读写权限。为此,请单击您的 github 组织(不是 repo)、设置、操作、常规,向下滚动到工作流程权限
我想补充一点,只选择第一个选项“读写权限”而不选中“允许 GitHub 操作创建和批准拉取请求”复选框对我也有效。
如果回购属于一个组织,您还必须在组织的操作设置中更改相同的工作流程权限。