-
Notifications
You must be signed in to change notification settings - Fork 1
feat/uis-package-bump-automation #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,155 @@ | ||
| name: 'Package bump make PR' | ||
| description: 'Package bump and open or update a pull request' | ||
|
|
||
| inputs: | ||
| gh_token: | ||
| description: 'GitHub token' | ||
| required: true | ||
| folder_path: | ||
| description: 'Folder path' | ||
| required: false | ||
| repository_url: | ||
| description: 'Repository url' | ||
| required: true | ||
| repository_branch: | ||
| description: 'Repository base branch' | ||
| required: false | ||
| default: 'dev' | ||
| pull_request_branch: | ||
| description: 'Branch to push package bump changes to' | ||
| required: false | ||
| default: 'chore/package-bump' | ||
| pull_request_title: | ||
| description: 'Pull request title' | ||
| required: false | ||
| default: 'chore: package bump' | ||
| pull_request_body: | ||
| description: 'Pull request body' | ||
| required: false | ||
| default: 'Automated package bump.' | ||
| commit_message: | ||
| description: 'Commit message' | ||
| required: false | ||
| default: 'chore: package bump' | ||
| propagation_delay: | ||
| description: 'Seconds to wait for npm package propagation before installing' | ||
| required: false | ||
| default: '30' | ||
| post_install_command: | ||
| description: 'Optional command to run after installing dependencies' | ||
| required: false | ||
| default: '' | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Wait for npm propagation | ||
| shell: bash | ||
| run: | | ||
| DELAY="${{ inputs.propagation_delay }}" | ||
| echo "Waiting ${DELAY}s for npm package propagation..." | ||
| sleep "$DELAY" | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| path: tmp | ||
| token: ${{ inputs.gh_token }} | ||
| repository: ${{ inputs.repository_url }} | ||
| ref: ${{ inputs.repository_branch }} | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24.4.0 | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: '10' | ||
|
|
||
| - name: Install dependencies | ||
| shell: bash | ||
| run: | | ||
| if [ -n "${{ inputs.folder_path }}" ]; then | ||
| cd "tmp/${{ inputs.folder_path }}" | ||
| else | ||
| cd tmp | ||
| fi | ||
| pnpm install | ||
|
|
||
| - name: Run post-install command | ||
| if: inputs.post_install_command != '' | ||
| shell: bash | ||
| run: | | ||
| if [ -n "${{ inputs.folder_path }}" ]; then | ||
| cd "tmp/${{ inputs.folder_path }}" | ||
| else | ||
| cd tmp | ||
| fi | ||
| ${{ inputs.post_install_command }} | ||
|
|
||
| - name: Prepare Nuxt | ||
| shell: bash | ||
| run: | | ||
| if [ -n "${{ inputs.folder_path }}" ]; then | ||
| cd "tmp/${{ inputs.folder_path }}" | ||
| else | ||
| cd tmp | ||
| fi | ||
|
|
||
| # Only run nuxi prepare if this is a Nuxt project | ||
| if [ -f "nuxt.config.ts" ] || [ -f "nuxt.config.js" ]; then | ||
| echo "Nuxt config found, running nuxi prepare..." | ||
| npx nuxi prepare | ||
| else | ||
| echo "No Nuxt config found, skipping nuxi prepare" | ||
| fi | ||
|
|
||
| - name: Create or update pull request | ||
| shell: bash | ||
| env: | ||
| GH_TOKEN: ${{ inputs.gh_token }} | ||
| REPOSITORY_URL: ${{ inputs.repository_url }} | ||
| BASE_BRANCH: ${{ inputs.repository_branch }} | ||
| PR_BRANCH: ${{ inputs.pull_request_branch }} | ||
| PR_TITLE: ${{ inputs.pull_request_title }} | ||
| PR_BODY: ${{ inputs.pull_request_body }} | ||
| COMMIT_MESSAGE: ${{ inputs.commit_message }} | ||
| run: | | ||
| cd tmp | ||
| git config user.name "${{ github.actor }}" | ||
| git config user.email "${{ github.actor }}@users.noreply.github.com" | ||
|
|
||
| # Check if there are any changes to commit | ||
| if [ -z "$(git status --porcelain)" ]; then | ||
| echo "No changes to commit" | ||
| exit 0 | ||
| fi | ||
|
|
||
| git fetch origin "${PR_BRANCH}:refs/remotes/origin/${PR_BRANCH}" || true | ||
| git checkout -B "${PR_BRANCH}" | ||
| git add . | ||
| git commit -m "${COMMIT_MESSAGE}" | ||
| git push --force-with-lease origin "HEAD:${PR_BRANCH}" | ||
|
|
||
| existing_pr_url="$(gh pr list \ | ||
| --repo "${REPOSITORY_URL}" \ | ||
| --head "${PR_BRANCH}" \ | ||
| --base "${BASE_BRANCH}" \ | ||
| --state open \ | ||
| --json url \ | ||
| --jq '.[0].url // empty')" | ||
|
|
||
| if [ -n "${existing_pr_url}" ]; then | ||
| echo "Updated existing pull request: ${existing_pr_url}" | ||
| exit 0 | ||
| fi | ||
|
|
||
| gh pr create \ | ||
| --repo "${REPOSITORY_URL}" \ | ||
| --base "${BASE_BRANCH}" \ | ||
| --head "${PR_BRANCH}" \ | ||
| --title "${PR_TITLE}" \ | ||
| --body "${PR_BODY}" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.