-
Notifications
You must be signed in to change notification settings - Fork 11
84 lines (68 loc) · 2.64 KB
/
create-tag-on-merge.yml
File metadata and controls
84 lines (68 loc) · 2.64 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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 });
// Extract only the Purpose section from PR description
let releaseNote = pr.title;
if (pr.body) {
const purposeMatch = pr.body.match(/Purpose:\s*([^\n]+)/);
if (purposeMatch) {
releaseNote = purposeMatch[1].trim();
}
}
core.setOutput('pr-title', pr.title);
core.setOutput('release-notes', releaseNote);
core.setOutput('pr-number', pr.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: |
PR_TITLE="${{ steps.should-deploy.outputs.pr-title }}"
RELEASE_NOTES="${{ steps.should-deploy.outputs.release-notes }}"
PR_NUMBER="${{ steps.should-deploy.outputs.pr-number }}"
# Create release notes with PR title, description, and link
cat > release_notes.md << EOF
## ${PR_TITLE}
${RELEASE_NOTES}
**Pull Request:** [#${PR_NUMBER}](https://github.com/${{ github.repository }}/pull/${PR_NUMBER})
EOF
cat release_notes.md
# gh release create $NEW_TAG --notes-file release_notes.md
# git checkout $NEW_TAG
# npm run update-v2-tag