Skip to content

Latest commit

 

History

History
77 lines (65 loc) · 1.71 KB

README.md

File metadata and controls

77 lines (65 loc) · 1.71 KB

Github Tag Check

Supported languages/frameworks

This currently looks for versions in the following files:

  • pyproject.toml
  • package.json
  • ./lib/*/version.rb
  • Dockerfile

Usage

See action.yml for inputs. The usage is very straightforward:

  1. Look for a version within your app.
  2. Check GitHub for a matching tag.
  3. Exit if a tag is found, or can't reach GitHub.

Use when you want to tag a commit.

# .github/workflows/git_tag.yaml

on:
  push:
    branches:
      - master
name: Git Tag
env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
  check_version:
    name: Check Version
    runs-on: ubuntu-latest
    outputs:
      git_tag_name: ${{ steps.tag_check.outputs.git_tag_name }}
    steps:
      - uses: actions/checkout@v2 # https://github.com/actions/checkout
      - uses: dudo/[email protected]
        id: tag_check
        with:
          git_tag_prefix: v
  push_tag:
    name: Push Tag
    needs: check_version
    runs-on: ubuntu-latest
    steps:
    - name: Push Tag to GitHub
      run: |
        curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
        -d "{\"ref\": \"refs/tags/${{needs.check_version.outputs.git_tag_name}}\", \"sha\": \"${GITHUB_SHA}\"}" \
        "https://api.github.com/repos/${GITHUB_REPOSITORY}/git/refs"

Or when you want to ensure you updated your version file.

# .github/workflows/check_tag.yaml

on:
  pull_request:
    branches:
      - master
name: Check Version
jobs:
  check_version:
    name: Check Version
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v2 # https://github.com/actions/checkout
      - uses: dudo/[email protected]
        with:
          git_tag_prefix: v