Create PR on dependent project #1
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: Create PR on dependent project | ||
on: | ||
workflow_call: | ||
inputs: | ||
libraryName: | ||
description: "Name of this library (e.g., gisce/commitlint-rules)" | ||
Check failure on line 7 in .github/workflows/create_dependent_pr.yaml GitHub Actions / Create PR on dependent projectInvalid workflow file
|
||
required: true | ||
default: "gisce/commitlint-rules" | ||
dependentProject: | ||
description: "Name of dependent projects (e.g., gisce/ooui.js)" | ||
required: true | ||
default: "gisce/ooui.js" | ||
dependentProjectBranch: | ||
description: "Name of the branch for the dependent project (e.g., alpha)" | ||
required: true | ||
default: "alpha" | ||
tagName: | ||
description: "Name of the tag (e.g., v1.0.0-alpha.0)" | ||
required: true | ||
default: "v1.0.0-alpha.0" | ||
workflow_dispatch: | ||
jobs: | ||
create-pr: | ||
steps: | ||
- name: Checkout dependent project repository | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: ${{ github.event.inputs.dependentProject }} | ||
ref: ${{ github.event.inputs.dependentProjectBranch }} | ||
token: ${{ secrets.GH_PAT }} | ||
- name: Update library version in package.json | ||
run: | | ||
NEW_VERSION=${{ github.event.inputs.tagName }} | ||
NEW_VERSION=${NEW_VERSION#v} # Remove the leading 'v' | ||
sed -i 's|"@${{ github.event.inputs.libraryName }}": "[^"]*"|"@${{ github.event.inputs.libraryName }}": "'"$NEW_VERSION"'"|' package.json | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "20.5.0" | ||
- name: Install npm dependencies and generate package-lock.json | ||
run: | | ||
npm install | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
token: ${{ secrets.GH_PAT }} | ||
commit-message: "fix: Update ${{ github.event.inputs.libraryName }} to ${{ github.event.release.tag_name }}" | ||
title: "Update ${{ github.event.inputs.libraryName }} to ${{ github.event.release.tag_name }}" | ||
branch: "update-${{ github.event.inputs.libraryName }}-${{ github.event.release.tag_name }}" |