DEV Community

Cover image for Use GitHub actions to auto tag your repo
Shivam
Shivam

Posted on

Use GitHub actions to auto tag your repo

In this post we will learn how we can leverage GitHub Action to tag the repository whenever there is a push on the main branch.

Normally developers tend to forget tagging the repository whenever some new stable code is merged on the main branch and eventually deployed on production. This workflow specified in this post aims to automate this tagging process.

Actions used in this blog can be find on:

GitHub logo shivamarora1 / gitaction_tag

Make a tag whenever there is push to the master branch

This repository contains a GitHub Action which will tag the repository whenever there is a push on the main branch. Normally developers tend to forget tagging the repository whenever some new stable code is merged on the main branch and eventually deployed on production. This workflow aims to automate the tagging process whenever there is a new deployment on main branch.

Some background on Git tag and GitHub actions

Git Tag

Tags are like way to create a snapshot of Git repo. Git tags are reference that point to specific points in the Git history. A tag is a branch which never change. Tags are generally marked as semantic versioning (v1.2.3) .

Creating a tag:

git tag <tag_name>

Publishing a tag:

git push origin <tag_name>

More info on tagging

GitHub Actions

GitHub Actions is a platform that helps to automate the processes in software build, test, and…

Some points used in above repository:

  1. Each running GitHub action has a unique run id that can be accessed using github context : ${{github.run_id}}
  2. uses: actions/checkout@v2 This step is used to checkout latest copy of your repository.
  3. This GitHub Action is executed whenever there is push event on main branch.

Top comments (0)