Skip to main content

GitHub QA

· One min read
Alan

GitHub 使用介绍

GitHub Action

获取分支名

via How to get branch name on GitHub action?

You can create a step output of the last part of GITHUB_REF like the following:

on: push
jobs:
example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set output
id: vars
run: echo ::set-output name=short_ref::${GITHUB_REF#refs/*/}

- name: Check output
run: echo ${{ steps.vars.outputs.short_ref }} # 这个地方就可以拿到上一步骤 vars 创建的输出了

添加Action徽章

via Adding a workflow status badge

徽章URL格式为: https://github.com/<OWNER>/<REPOSITORY>/actions/workflows/<WORKFLOW_FILE>/badge.svg

假设工作流文件路径为 .github/workflows/main.yml, 仓库的 OWNERgithub 组织, REPOSITORY 名称为 docs, 其徽章为 https://github.com/github/docs/actions/workflows/main.yml/badge.svg

也可以加上分支名称: https://github.com/github/docs/actions/workflows/main.yml/badge.svg?branch=feature-1