Skip to content

Git - Rename Tag

Git - Rename Tag #3

name: 'Git - Rename Tag'
on:
workflow_dispatch:
inputs:
old_tag:
description: 'Numerical only e.g. 1.0.0'
required: true
type: 'string'
new_tag:
description: 'Numerical only e.g. 1.1.0'
required: true
type: 'string'
permissions:
pull-requests: write
id-token: write # This is required for requesting the JWT
contents: write # This is required for actions/checkout
jobs:
tag_renaming_process:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.old_tag }}
fetch-depth: 0
- name: Check SHA
id: get-sha
run: |
echo "BRANCH_SHA=$(git log -1 '--format=format:%H')">> $GITHUB_OUTPUT
- name: Check SHA value
run: |
echo Branch SHA: ${{steps.get-sha.outputs.BRANCH_SHA}}
- name: Create tag
uses: actions/github-script@v7
with:
script: |
console.log(context)
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{github.event.inputs.new_tag}}',
sha:'${{steps.get-sha.outputs.BRANCH_SHA}}'
})