栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

从GitHub动作推到起源

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

从GitHub动作推到起源

动作/结帐@ v2

签出的版本2解决了分离的HEAD状态问题,并简化了向原点的推送。

name: Push commiton: pushjobs:  report:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v2      - name: Create report file        run: date +%s > report.txt      - name: Commit report        run: |          git config --global user.name 'Your Name'          git config --global user.email 'your-username@users.noreply.github.com'          git commit -am "Automated report"          git push

如果您需要push事件来触发其他工作流程,请使用

repo
范围限定的Personal Access
Token

      - uses: actions/checkout@v2        with:          token: ${{ secrets.PAT }}

动作/结帐@ v1(原始答案)

在@rmunn的出色答案中添加更多详细信息。问题是该

actions/checkout@v1
操作使git存储库处于分离的HEAD状态。请参阅此问题以获取更多详细信息:https
:
//github.com/actions/checkout/issues/6

这是一个完整的示例,以演示如何使已签出的存储库进入可用状态并推送到远程服务器。

name: Push commiton: pushjobs:  report:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v1      - name: Create report file        run: date +%s > report.txt      - name: Commit report        run: |          git config --global user.name 'Your Name'          git config --global user.email 'your-username@users.noreply.github.com'          git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY          git checkout "${GITHUB_REF:11}"          git commit -am "Automated report"          git push

要包括未跟踪的(新)文件,请更改工作流程以使用以下内容。

          git add -A          git commit -m "Automated report"

以上工作流程应适用于大多数事件。对于

on: pull_request
工作流,
GITHUB_HEAD_REF
应检出合并分支()以替换默认的合并提交。

重要提示:
如果除了以下工作流程之外还进行其他拉取请求检查,则必须使用个人访问令牌代替默认访问令牌

GITHUB_TOKEN
。这是由于GitHub
Actions故意施加的限制,由工作流程引发的事件(例如
push
)无法触发进一步的工作流程运行。这是为了防止意外的“无限循环”情况,并且是一种防止滥用的措施。使用
repo
范围限定的个人访问令牌是一种公认​​的解决方法。有关解决方法的更多详细信息,请参见此GitHub问题。

name: Push commit on pull requeston: pull_requestjobs:  report:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v1        with:          ref: ${{ github.head_ref }}      - name: Create report file        run: date +%s > report.txt      - name: Commit report        run: |          git config --global user.name 'Your Name'          git config --global user.email 'your-username@users.noreply.github.com'          git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}          git commit -am "Automated report"          git push

有关在

on: pull_request
工作流期间推送到原点的更多示例,请参阅此博客文章GitHub Actions:如何在Pull
Requests中自动执行代码格式设置。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/409253.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号