在GitHub Actions中,是否可以访问已删除分支的名称? [英] In GitHub Actions, is it possible to access the name of a deleted branch?

查看:64
本文介绍了在GitHub Actions中,是否可以访问已删除分支的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过 delete事件.但是,据此,GITHUB_REF变量然后指向 default 分支,而不是被删除的分支. (类似于 push事件.)

It is possible to have a GitHub Action trigged by the delete event. However, according to those, the GITHUB_REF variable then points to the default branch, rather than the branch that was deleted. (Likewise for the push event.)

是否可以获取已删除的分支的名称?具体来说,我想使用为响应push事件而创建的分支名称的ID清理部署.

Is it possible to obtain the name of the branch that was deleted? Specifically, I'd like to clean up a deployment with the branch name's ID that was created in response to the push event.

推荐答案

您可以从github上下文访问github.event.refgithub.event.ref_type.

You can access github.event.ref and github.event.ref_type from the github context.

当其他引用类型也被删除时,该事件将触发.因此,您只需要过滤branch删除项即可.

The event will trigger when other ref types are deleted, too. So you need to filter just branch deletions.

name: Branch Deleted
on: delete
jobs:
  delete:
    if: github.event.ref_type == 'branch'
    runs-on: ubuntu-latest
    steps:
      - name: Clean up
        run: |
          echo "Clean up for branch ${{ github.event.ref }}"

这篇关于在GitHub Actions中,是否可以访问已删除分支的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆