Skip to content

Commit

Permalink
CI: comment back on the version bump PR after publishing to npm (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Aug 28, 2023
1 parent fcb7d6b commit 73f54d3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/gh-release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
echo "${{ steps.release-drafter.outputs.html_url }}"
} >> "${GITHUB_STEP_SUMMARY}"
# Comment back on the PR that caused this release
# Comment back on the PR that caused this push
- if: ${{ steps.release-drafter.outputs.id }}
id: pr-finder
run: |
Expand All @@ -107,7 +107,9 @@ jobs:
uses: thollander/actions-comment-pull-request@v2
with:
message: |
## :shipit: New Release
## :octocat: GitHub Release
This pull request resulted in the release: [v${{ steps.check.outputs.version }} @ ${{ env.ref }}](${{ steps.release-drafter.outputs.html_url }})
_Comment generated by the [${{ github.workflow }}](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}) workflow._
comment_tag: gh-release
pr_number: ${{ steps.pr-finder.outputs.PR_NUMBER }}
31 changes: 30 additions & 1 deletion .github/workflows/node-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,40 @@ jobs:
node-version-file: '.nvmrc'
cache: 'npm'
- run: npm ci
- name: npm publish
- id: publish
name: npm publish
# https://github.com/bitwarden/clients/pull/3272
run: |
echo 'registry="https://registry.npmjs.org/"' > ./.npmrc
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> ./.npmrc
npm publish --regsitry=https://registry.npmjs.org/ --userconfig=./.npmrc --provenance --access public
{
echo "PACKAGE_NAME=$(jq --raw-output '.name' package.json)"
echo "PACKAGE_VERSION=$(jq --raw-output '.version' package.json)"
} >> "${GITHUB_OUTPUT}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# Comment back on the PR that caused this push
- id: pr-finder
run: |
GIT_SHA=$(git rev-parse HEAD)
echo "${GIT_SHA}"
PR_NUMBER=$(curl -L \
--fail-with-body \
--silent \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GIT_SHA}/pulls" \
| jq --raw-output '.[0].number')
echo "PR_NUMBER=${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
- uses: thollander/actions-comment-pull-request@v2
with:
message: |
## :package: npm Publish
This pull request resulted in the npm release: [v${{ steps.publish.outputs.PACKAGE_VERSION }}](https://www.npmjs.com/package/${{ steps.publish.outputs.PACKAGE_NAME }}/v/${{ steps.publish.outputs.PACKAGE_VERSION }})
_Comment generated by the [${{ github.workflow }}](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}) workflow._
comment_tag: node-publish
pr_number: ${{ steps.pr-finder.outputs.PR_NUMBER }}
1 change: 1 addition & 0 deletions .github/workflows/pr-commenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ jobs:
```shell
npm exec --yes -- "github:${{ github.event.pull_request.head.repo.full_name }}#${{ github.event.pull_request.head.ref }}" [commands..] [options]
```
_Comment generated by the [${{ github.workflow }}](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}) workflow._
comment_tag: npm-exec
1 change: 1 addition & 0 deletions .github/workflows/pr-renamer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
```text
${{ steps.title-massager.outputs.ERROR }}
```
_Comment generated by the [${{ github.workflow }}](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}) workflow._
mode: ${{ steps.gh-pr-edit.outcome != 'success' && 'upsert' || 'delete' }}
create_if_not_exists: ${{ steps.gh-pr-edit.outcome != 'success' && 'true' || 'false' }}
comment_tag: pr-renamer
Expand Down

0 comments on commit 73f54d3

Please sign in to comment.