forked from illright/attractions
-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (46 loc) · 1.55 KB
/
suggest-release.yml
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
name: Suggest auto-releasing
on:
pull_request:
branches:
- main
types:
- opened
paths:
- "attractions/package.json"
jobs:
tag-issue:
name: Tag the PR with [new release] if needed
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Add the [new release] tag 🔖
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const package = require(`${process.env.GITHUB_WORKSPACE}/attractions/package.json`);
const currentVersion = `v${package.version}`;
const tags = (await github.repos.listTags({
owner: context.repo.owner,
repo: context.repo.repo,
})).data;
if (tags.find(tag => tag.name === currentVersion) == null) {
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['new release'],
});
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: (
'This pull request will automatically trigger a release on merge!\n'
+ 'If it shouldn\'t, remove the [new release] label.'
),
});
}