Skip to content

Commit 3ad5e9f

Browse files
ci(update-npm): use environments (#556)
1 parent 8fa1583 commit 3ad5e9f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

.github/workflows/__call-update-npm.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ on:
1616
jobs:
1717
publish-npm:
1818
runs-on: ubuntu-latest
19+
environment:
20+
name: ${{ matrix.environment }}
21+
url: ${{ steps.environment.outputs.url }}
1922
strategy:
2023
fail-fast: false
2124
matrix:
2225
include:
2326
- registry-url: "https://npm.pkg.github.com"
27+
environment: npm-gpr
2428
extra-args: ""
2529
- registry-url: "https://registry.npmjs.org"
30+
environment: npmjs
2631
extra-args: "--provenance --access public"
2732
steps:
2833
- name: Checkout
@@ -54,3 +59,14 @@ jobs:
5459

5560
- name: Publish
5661
run: npm publish ${{ matrix.extra-args }}
62+
63+
- name: Set environment output
64+
id: environment
65+
run: |
66+
if [[ "${{ matrix.environment }}" == "npm-gpr" ]]; then
67+
url="https://github.com/${{ github.repository }}/pkgs/npm/${{ github.event.repository.name }}"
68+
elif [[ "${{ matrix.environment }}" == "npmjs" ]]; then
69+
package_name=$(node -p "require('./package.json').name")
70+
url="https://www.npmjs.com/package/${package_name}"
71+
fi
72+
echo "url=${url}" >> "${GITHUB_OUTPUT}"

0 commit comments

Comments
 (0)