如何获取CurrentBranchName并将其用作工作流名称?(github动作)

时间:2020-02-20 10:26:39

标签: github-actions

我想知道如何处理这个问题标题。

我提到了这个。 How to get current branch within github actions

目标: 如果我能解决这个问题,很容易在Github Actions标签页索引中回顾哪个分支是推送/拉取请求。

enter image description here

情况:

分支就像这样的结构→主/分支/开发/任何分支

在创建pullrequest(在本例中为staging / development)到staging分支时,将运行


./.github/workflows/staging_pq.yml

    name: Staging-branch got pull-request by ${GITHUB_REF}
    on:
      pull_request:
        branches:
          - staging
    jobs:
      setup:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout
            uses: actions/checkout@v1

          - name: Setup Node
            uses: actions/setup-node@v1
            with:
              node-version: '12.x'

          - name:Check branch name
            run: echo running on branch ${GITHUB_REF#refs/heads/}

      test_and_check:
        needs: [setup]
        runs-on: ubuntu-latest
        steps:
          - name: Checkout
            uses: actions/checkout@v1

          - name: npm Install
            run: npm install

          - name: Setup dependencies
            run: npm ci

          - name: Unit tests
            run: npm run test:app

          - name: CDK Diff Check
            run: npm run cdk:diff

问题: 1,我在“检查分支名称”步骤中得到了不合适的值,例如“在分支refs / pull / 12 / merge上运行”。 我想“在分支开发上运行”。

2,我无法在工作流文件中第一行的“名称”中使用变量,并且找不到解决方案。

0 个答案:

没有答案