目前,我的存储库中有两个用于“发布GitHub页面”的工作流。
一个是我制作的‘构建GitHub页面’,‘页面-构建-部署’是由GitHub为GitHub页面发布注册的。

我不喜欢这样。我希望这两个工作流合并为一个。
有两个原因。
首先,“页面-构建-部署”运行两次。第一次取消,第二次正常运行。那是因为我修改了“h页”分支的文件,以美化文件。触发“页面-构建-部署”运行两次。我不想这样。这使得工作流日志在一次提交中有三个条目。是的,这是个人喜好。
其次,我希望看到发布GitHub页面的完整状态。即使“构建GitHub页面”操作成功,我也必须等待“页面-构建-部署”来完成它的工作,才能真正运行页面。
所以,我写了这样的工作流文件。
name: Build GitHub Pages
on:
push:
branches:
- main
jobs:
build:
name: Build GitHub Pages
runs-on: ubuntu-latest
steps:
- name: Checkout latest commit
uses: actions/checkout@v3
- name: Prepare Python
uses: actions/setup-python@v3
with:
python-version: 3.x
- name: Install requirements (mkdocs-material)
run: |
echo "Installing mkdocs-material"
pip install mkdocs-material
echo "Installing js-beautify"
npm install -g --location=global js-beautify --no-fund
- name: Build website
run: mkdocs gh-deploy --force
modify:
name: Modify Generated Files
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout latest commit of gh-pages
uses: actions/checkout@v3
with:
ref: gh-pages
- name: Prepare Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install requirements (js-beautify)
run: |
echo "Installing js-beautify"
npm install -g --location=global js-beautify --no-fund
- name: Beautify files
run: |
echo "Beautify files"
git checkout gh-pages
find . -type f -name '*.js' ! -name '*.min.js' -exec js-beautify -r '{}' --config jsbeautify.json --preserve-newlines false \;
find . -type f -name '*.css' ! -name '*.min.css' -exec css-beautify -r '{}' --config jsbeautify.json --preserve-newlines false \;
find . -type f -name '*.html' -exec html-beautify -r '{}' --config jsbeautify.json --preserve-newlines false \;
- name: Manually set CNAME
run: |
echo "mydomain.com" > CNAME
git add CNAME
- name: Save changes to gh-pages branch
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply beautified files
branch: gh-pages
publish:
name: Publish GitHub Pages
runs-on: ubuntu-latest
needs: modify
steps:
- name: Checkout latest commit of gh-pages
uses: actions/checkout@v3
with:
ref: gh-pages
submodules: recursive
- name: Upload page artifact
uses: actions/upload-pages-artifact@v0
with:
path: .
- name: Upload artifact
uses: actions/upload-artifact@main
with:
name: github-pages
path: /home/runner/work/_temp/artifact.tar
retention-days: 1
report:
name: Report telemetry
runs-on: ubuntu-latest
needs: publish
steps:
- name: Report build status
uses: actions/deploy-pages@v1
with:
emit_telemetry: true
deploy:
name: Deploy GitHub Pages
runs-on: ubuntu-latest
needs: publish
steps:
- name: Deploy GitHub Pages
uses: actions/deploy-pages@v1
with:
emit_telemetry: false(忽略一些副本)
我试图尽可能多地模仿“页面-构建-部署”,但deploy部件失败了。我从操作日志中看到了这个错误消息,但是无法找到解决这个错误的方法。
Error: Error: Error message: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable我找不到ACTIONS_ID_TOKEN_REQUEST_URL是在“页面-构建-部署”中定义的,所以我不知道我的设置有什么问题。
TL;DR
如何解决GitHub工作流中的错误消息?
Error: Error: Error message: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable在“原始”工作流中,我看不到ACTIONS_ID_TOKEN_REQUEST_URL中的任何用法。
发布于 2022-10-22 21:35:15
你的需要决定了
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: writehttps://stackoverflow.com/questions/72504998
复制相似问题