-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add preview package code (disabled) (#19)
- Loading branch information
1 parent
0f303bf
commit 957cfb1
Showing
3 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: On closing PR | ||
on: | ||
pull_request_target: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
unpublish: | ||
name: Unpublish or Deprecate NPM previews for PR | ||
runs-on: ubuntu-latest | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PRIVATE_PUBLISH }} | ||
steps: | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Remove preview consumption comment | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: pr_preview_consumption | ||
delete: true | ||
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }} | ||
|
||
- name: Create .npmrc | ||
# Reference the env variable NPM_TOKEN here, not the secret | ||
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc | ||
|
||
- name: Unpublish | ||
run: | | ||
toUnpublish=() | ||
prNumber="${{github.event.number}}" | ||
pkgName="@kong/design-system" | ||
npm dist-tag rm "${pkgName}" "pr-${prNumber}" || true | ||
for pkgVersion in $(npm view ${pkgName} --json|jq -r .versions|grep "\-pr.${prNumber}."|sed 's/,//'| sed 's/\"//g') | ||
do | ||
toUnpublish+=("${pkgName}@${pkgVersion}") | ||
done | ||
echo "List: ${toUnpublish[*]}"|sed 's/ /\n/g' | ||
for (( i=${#toUnpublish[@]}-1; i>=0; i-- )) | ||
do | ||
echo "" | ||
echo "*** deprecating: ${toUnpublish[i]}" | ||
npm deprecate --force "${toUnpublish[i]}" "Deprecated PR preview" || true | ||
done | ||
for (( i=${#toUnpublish[@]}-1; i>=0; i-- )) | ||
do | ||
echo "" | ||
echo "unpublishing: ${toUnpublish[i]}" | ||
npm unpublish --force "${toUnpublish[i]}" || true | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ on: | |
push: | ||
branches: | ||
- main | ||
- beta | ||
|
||
jobs: | ||
run-tests: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters