Skip to content

Commit ff1bd8c

Browse files
committed
chore: changes trigger hook to be pull_request
1 parent 728a752 commit ff1bd8c

1 file changed

Lines changed: 10 additions & 60 deletions

File tree

Lines changed: 10 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,24 @@
11
name: Publish Package
22

33
on:
4-
issue_comment:
5-
types: [created]
6-
pull_request_review_comment:
7-
types: [created]
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
# runs on main PRs targeting main
8+
- main
89

910
permissions:
10-
contents: write
11-
packages: write
12-
issues: write
13-
pull-requests: write
11+
contents: write # To push version bump commit and tag
1412

1513
jobs:
1614
publish:
17-
if: ${{ startsWith(github.event.comment.body, '/publish') }}
15+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
1816
runs-on: ubuntu-latest
1917
steps:
20-
- name: Check if commenter has write access
21-
id: check_permissions
22-
uses: actions-cool/check-user-permission@v2
23-
with:
24-
require: "write"
25-
username: ${{ github.event.comment.user.login }}
26-
27-
- name: Fail if user doesn't have permissions
28-
if: steps.check_permissions.outputs.require-result != 'true'
29-
run: |
30-
echo "::error::Only users with write permissions can run this workflow."
31-
exit 1
32-
33-
- name: Extract version type
34-
id: version-type
35-
run: |
36-
COMMENT="${{ github.event.comment.body }}"
37-
if [[ "$COMMENT" == "/publish major" ]]; then
38-
echo "type=major" >> $GITHUB_OUTPUT
39-
elif [[ "$COMMENT" == "/publish minor" ]]; then
40-
echo "type=minor" >> $GITHUB_OUTPUT
41-
elif [[ "$COMMENT" == "/publish patch" ]]; then
42-
echo "type=patch" >> $GITHUB_OUTPUT
43-
else
44-
echo "Unknown version type. Use '/publish major', '/publish minor', or '/publish patch'"
45-
exit 1
46-
fi
47-
4818
- name: Checkout
4919
uses: actions/checkout@v3
5020
with:
21+
ref: "main"
5122
fetch-depth: 0
5223
token: ${{ secrets.GITHUB_TOKEN }}
5324

@@ -72,7 +43,8 @@ jobs:
7243
- name: Bump version
7344
id: bump-version
7445
run: |
75-
VERSION_TYPE="${{ steps.version-type.outputs.type }}"
46+
# Defaulting to patch release, as trigger no longer specifies type
47+
VERSION_TYPE="patch"
7648
yarn version --"$VERSION_TYPE" --no-git-tag-version
7749
NEW_VERSION=$(node -p "require('./package.json').version")
7850
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
@@ -100,25 +72,3 @@ jobs:
10072
run: yarn publish
10173
env:
10274
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
103-
104-
- name: Comment on issue/PR
105-
uses: actions/github-script@v6
106-
with:
107-
github-token: ${{ secrets.GITHUB_TOKEN }}
108-
script: |
109-
const issueNumber = context.issue.number || context.payload.pull_request?.number;
110-
if (!issueNumber) {
111-
console.log("Could not determine issue/PR number");
112-
return;
113-
}
114-
115-
const newVersion = '${{ steps.bump-version.outputs.new_version }}';
116-
const releaseUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/releases/tag/v${newVersion}`;
117-
const npmUrl = `https://www.npmjs.com/package/@jam.dev/sdk/v/${newVersion}`;
118-
119-
await github.rest.issues.createComment({
120-
owner: context.repo.owner,
121-
repo: context.repo.repo,
122-
issue_number: issueNumber,
123-
body: `🎉 Version v${newVersion} has been published!\n\n- [GitHub Release](${releaseUrl})\n- [NPM Package](${npmUrl})`
124-
});

0 commit comments

Comments
 (0)