Skip to content

Commit 4b90fb0

Browse files
SRAlexanderScott Alexander
andauthored
Prmdr tag rename action added to repo (#173)
New action that creates a new tag from a previous tag has been added. --------- Co-authored-by: Scott Alexander <[email protected]>
1 parent 93d19bf commit 4b90fb0

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

.github/workflows/git-rename-tag.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,38 @@ on:
1515
permissions:
1616
pull-requests: write
1717
id-token: write # This is required for requesting the JWT
18-
contents: read # This is required for actions/checkout
18+
contents: write # This is required for actions/checkout
1919

2020
jobs:
2121
tag_renaming_process:
2222
runs-on: ubuntu-latest
23+
permissions: write-all
2324

2425
steps:
25-
26+
2627
- name: Checkout
2728
uses: actions/checkout@v3
2829
with:
29-
ref: main
30-
31-
- name: Get and create new tag
32-
id: init
30+
ref: ${{ github.event.inputs.old_tag }}
31+
fetch-depth: 0
32+
33+
- name: Check SHA
34+
id: get-sha
3335
run: |
34-
git checkout ${{ github.event.inputs.old_tag}}
35-
git tag ${{ github.event.inputs.new_tag}}
36-
git push origin ${{ github.event.inputs.new_tag}}
37-
38-
working-directory: ./
39-
shell: bash
36+
echo "BRANCH_SHA=$(git log -1 '--format=format:%H')">> $GITHUB_OUTPUT
37+
38+
- name: Check SHA value
39+
run: |
40+
echo Branch SHA: ${{steps.get-sha.outputs.BRANCH_SHA}}
41+
42+
- name: Create tag
43+
uses: actions/github-script@v7
44+
with:
45+
script: |
46+
console.log(context)
47+
github.rest.git.createRef({
48+
owner: context.repo.owner,
49+
repo: context.repo.repo,
50+
ref: 'refs/tags/${{github.event.inputs.new_tag}}',
51+
sha:'${{steps.get-sha.outputs.BRANCH_SHA}}'
52+
})

0 commit comments

Comments
 (0)