Update package #9
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
name: Update package | |
on: | |
workflow_dispatch: | |
inputs: | |
package: | |
description: 'Package name' | |
required: true | |
type: string | |
version: | |
description: 'Package version' | |
required: true | |
type: string | |
default: "latest" | |
jobs: | |
update-package: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'npm' | |
- run: npm ci | |
- name: Update package | |
run: npm i ${{ inputs.package }}@${{ inputs.version }} | |
- name: Create and publish PR | |
env: | |
GH_TOKEN: ${{ secrets.YC_UI_BOT_GITHUB_TOKEN }} | |
run: | | |
set -e | |
[[ -z $(git diff --stat | grep package.json) ]] && echo "::info::Nothing to update" && exit 0 | |
VERSION=$(npm explore --no-workspaces ${{ inputs.package }} "node -pe 'require(\"./package.json\").version'" --shell sh) | |
git config --global user.email "[email protected]" | |
git config --global user.name "yc-ui-bot" | |
git push -f origin :ci/update-deps/${{ inputs.package }}-$VERSION || true | |
git checkout -b ci/update-deps/${{ inputs.package }}-$VERSION | |
git add package.json package-lock.json | |
git commit -m "deps: Update ${{ inputs.package }} to $VERSION" | |
git push -u origin ci/update-deps/${{ inputs.package }}-$VERSION | |
gh pr create -f |