-
Notifications
You must be signed in to change notification settings - Fork 5
61 lines (53 loc) · 1.56 KB
/
tag.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Automated tag
on:
issue_comment:
types:
- created
pull_request:
branches:
- main
types:
- closed
permissions:
contents: write
id-token: write
pull-requests: read
jobs:
create-tag:
name: tag
runs-on: ubuntu-24.04
environment: automated
if: >
(startsWith(github.event.issue.title, 'Automated npm version') &&
github.event.issue.state == 'closed' &&
github.event.comment.body == '/tag') ||
(startsWith(github.event.pull_request.title, 'Automated npm version') &&
github.event.pull_request.merged)
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Get version from package.json
id: package-json
run: |
echo "version=$(jq -r .version freelens/package.json)" >> $GITHUB_OUTPUT
- name: Create tag from the main branch
if: steps.package-json.outputs.version
uses: actions/github-script@v7
with:
script: |
const mainRef = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'heads/main',
});
const result = await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v${{ steps.package-json.outputs.version }}',
sha: mainRef.data.object.sha,
});
console.log(result);
github-token: ${{ secrets.GH_TOKEN }}