Get the current pushed tag in Github Actions

前端 未结 4 446
别跟我提以往
别跟我提以往 2021-01-31 08:12

Is there a way to access the current tag that has been pushed in a Github Action? In CircleCI you can access this value with the $CIRCLE_TAG variable.

My Wor

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 09:15

    Here's a workflow run showing that the GITHUB_REF environment variable contains refs/tags/v0.0.2:

    I ran that by creating the tag, then doing git push origin v0.0.2.

    Here's a snippet of the workflow you see in that log:

    steps:
    - uses: actions/checkout@v1
    - name: Dump GitHub context
      env:
        GITHUB_CONTEXT: ${{ toJson(github) }}
      run: echo "$GITHUB_CONTEXT"
      if: runner.os != 'Windows'
    - name: Show GitHub ref
      run: echo "$GITHUB_REF"
      if: runner.os != 'Windows'
    - name: Dump event JSON
      env:
        EVENT_JSON_FILENAME: ${{ github.event_path }}
      run: cat "$EVENT_JSON_FILENAME"
      if: runner.os != 'Windows'
    

    Since the log has been deleted, here's a screenshot for evidence:

提交回复
热议问题