Giter Site home page Giter Site logo

ref-to-tag-action's Introduction

ref-to-tag Github Action

This action uses your Github context to extract your branch or tag name for use in other steps. It also formats the name to be compatible for use as the name of a docker container.

  • On a pull request, this will use the "head" branch of your PR. i.e. the branch that you are merging into the base branch.
  • On pushing a branch, it'll return the name of the branch you're pushing to.
  • On pushing a tag, it'll return the name of the tag.
  • Any slashes in the branch/tag names are converted to dots to make them valid with Docker but unlikely to collide with other branch names.

Branch -> Tag Examples:

- PR feature/my-branch -> feature.my-branch
- PR feature/my/weird/branchname -> feature.my.weird.branchname
- push to feature/my-branch -> feature.my-branch
- push to my-branch -> my-branch
- release/push of v1.0.5 tag -> v1.0.5

Note that you should always pass both the github.ref and github.head_ref, and the script is smart enough to know which to look at depending on which are filled.

Inputs

ref

Required Pass ${{ github.ref }}.

head_ref

Required Pass ${{ github.head_ref }}.

Note that if this is a push to a branch (and not a PR), the head_ref will be an empty string. That is fine, the action will know to ignore it.

Outputs

tag

The tag it parsed for you.

Example usage

See .github/workflows/example.yaml for a working example in this repo.

on: [pull_request, push]

jobs:
  get-ref-example:
    runs-on: ubuntu-latest
    name: get-ref-example
    steps:
    - name: Get the Ref
      id: get-ref
      uses: ankitvgupta/ref-to-tag-action@master
      with:
        ref: ${{ github.ref }}
        head_ref: ${{ github.head_ref }}
    - name: Get the tag
      run: echo "The tag was ${{ steps.get-ref.outputs.tag }}"

ref-to-tag-action's People

Contributors

ankitvgupta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.