Skip to content

Dispatch workflow for a bot for set_version PR #302

Description

@sunya-ch

Describe the solution you'd like

To reduce steps for release, we can add a workflow to have a bot to run make set_version and create a PR towards main.

Additional context

name: make set_version and push PR if changes

on:
  workflow_dispatch:
    inputs:
      version:
        description: 'image version X.Y.Z (without `v`)'
        required: true

env:
  NEW_VERSION: ${{ github.event.inputs.version }}

jobs:
  run-and-pr:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4

      - name: Set version
        run: |
          make set_version ${{ env.NEW_VERSION }}.

      - name: Commit changes if any
        id: commit_changes
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add .
          # Try to commit, capture output
          if git diff --cached --quiet; then
            echo "No changes to commit"
            echo "changes=false" >> $GITHUB_OUTPUT
          else
            git commit -m "chore: make set_version"
            echo "changes=true" >> $GITHUB_OUTPUT
          fi

      - name: Create Pull Request
        if: steps.commit_changes.outputs.changes == 'true'
        uses: peter-evans/create-pull-request@v5
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: chore: make set_version ${{ env.NEW_VERSION }}
          branch: update-branch
          base: main
          title: Automated update PR
          body: This PR was created automatically by GitHub Actions to set version to ${{ env.NEW_VERSION }}.
          draft: false

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions