auto-merge dependabot prs into collected branch #14
  
    
      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
    
  
  
    
  | # qqqq in development | |
| # this script seperate major and minor but we do merge them into the same branch. | |
| # having two steps allows us to easily turn off major changes in future and then script them to their own branch and pipeline. | |
| name: auto-merge dependabot prs into collected branch | |
| on: | |
| pull_request: | |
| # synchronize | |
| types: [opened, synchronize] | |
| branches: [automatic_version_update_dependabot] # make sure this matches your actual branch name | |
| check_suite: | |
| types: [completed] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| checks: read | |
| jobs: | |
| debug: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: debug info | |
| run: | | |
| echo "actor: ${{ github.actor }}" | |
| echo "pr title: ${{ github.event.pull_request.title }}" | |
| echo "target branch: ${{ github.event.pull_request.base.ref }}" | |
| echo "source branch: ${{ github.event.pull_request.head.ref }}" | |
| - name: delay for check | |
| run: | | |
| # drop later qqqq shouldnt need but its running before auto | |
| echo "waiting 4 minutes for other checks to start running..." | |
| sleep 240 | |
| auto-merge: | |
| runs-on: ubuntu-latest | |
| # if dependabot and checks ran | |
| if: (github.actor == 'dependabot[bot]' || github.event_name == 'workflow_dispatch')&& (github.event_name != 'check_suite' || github.event.check_suite.conclusion == 'success') | |
| steps: | |
| - name: extract update type | |
| id: extract | |
| run: | | |
| pr_title="${{ github.event.pull_request.title }}" | |
| if [[ $pr_title == *"(major)"* ]]; then | |
| echo "update_type=major" >> $github_output | |
| else | |
| echo "update_type=minor_or_patch" >> $github_output | |
| fi | |
| - name: auto-merge minor and patch updates | |
| if: steps.extract.outputs.update_type == 'minor_or_patch' | |
| # auto should set the the request to merge once checks complete | |
| # qqqq could squash for cleaner? --squash "${{ github.event.pull_request.html_url }}" | |
| run: gh pr merge --auto 1 | |
| env: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: auto-merge major updates | |
| if: steps.extract.outputs.update_type == 'major' | |
| # auto should set the the request to merge once checks complete | |
| # qqqq could squash for cleaner? --squash "${{ github.event.pull_request.html_url }}" | |
| run: gh pr merge --auto 1 | |
| env: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} |