-
Notifications
You must be signed in to change notification settings - Fork 11
54 lines (47 loc) · 1.56 KB
/
create-tag-on-merge.yml
File metadata and controls
54 lines (47 loc) · 1.56 KB
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
name: Create Tag on merge
on:
workflow_dispatch:
push:
branches:
- develop
paths:
- src/**
- dist/**
- package*.json
jobs:
create-tag:
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Create and push new tag
run: npm run create-tag
- name: Get latest commit
id: get-commit
run: echo "LAST_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Check for associated pull request and auto-deploy label
id: should-deploy
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const commit_sha = '${{ env.LAST_SHA }}';
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ commit_sha, owner, repo });
if (prs?.length > 0) {
const pull_number = prs[0].number;
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });
return pr.labels.some(label => label.name.includes('auto-deploy'));
}
return false;
- name: Create GitHub Release & Deploy
if: steps.should-deploy.outputs.result == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create $NEW_TAG --generate-notes
git checkout $NEW_TAG
npm run update-v2-tag