Skip to content

feat(*): create package #56

feat(*): create package

feat(*): create package #56

Workflow file for this run

name: Tests
on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
branches:
- main
# Allow calling manually from GitHub
workflow_dispatch:
# Allow workflow to be called by another workflow
workflow_call:
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Remove preview consumption comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr_preview_consumption
delete: true
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PNPM with Dependencies
uses: ./.github/actions/setup-pnpm-with-dependencies/
with:
force-install: true
- name: Stylelint
run: pnpm run stylelint
- name: Lint
run: pnpm run lint
- name: Build
run: pnpm run build
- name: Test
run: pnpm run test
- name: Publish package preview
id: package-preview
if: github.event_name == 'pull_request' && (github.actor != 'renovate[bot]' || contains(github.event.pull_request.labels.*.name, 'create preview package'))
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLIC_PUBLISH }}
run: |
git config user.email "[email protected]"
git config user.name "Kong UI Bot"
preid="pr.${{ github.event.pull_request.number }}.$(git rev-parse --short ${{ github.event.pull_request.head.sha }})"
tag="pr-${{ github.event.pull_request.number }}"
echo "preid=${preid}"
git checkout ${{ github.head_ref }}
pnpm --silent lerna version prerelease --preid ${preid} --allow-branch ${{ github.head_ref }} --conventional-prerelease --yes --amend || true
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
pnpmPublish=$(pnpm publish --no-git-checks --access public --report-summary --tag "${tag}")
if [[ ! -z $(echo "${pnpmPublish}"|grep "There are no new packages that should be published") ]]; then
echo "There are no new packages that should be published"
exit 0
fi
npm_instructions=""
pkg=$(echo "${pnpmPublish}" | grep "+ "| sed 's/+ //')
pkg="@$(echo ${pkg}|cut -d'@' -f2)@${tag}"
if [ "${npm_instructions}" != "" ]; then
npm_instructions="${npm_instructions}\n"
fi
npm_instructions="${npm_instructions}${pkg}"
if [[ -z "${npm_instructions}" ]]; then
echo "Error creating preview instructions"
exit -1
fi
echo "npm_instructions<<EOF" >> $GITHUB_ENV
echo -e "$npm_instructions" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Provide preview link info
if: ${{ steps.package-preview.outputs.npm_instructions != '' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr_preview_consumption
message: |
### Install the preview package from this PR
```sh
${{ steps.package-preview.outputs.npm_instructions }}
```
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }}