11# qqqq in development
2- # qqqq not getting the events
32# this script seperate major and minor but we do merge them into the same branch.
43# having two steps allows us to easily turn off major changes in future and then script them to their own branch and pipeline.
54name : auto-merge dependabot prs into collected branch
65on :
7- # pull_request:
8- # synchronize
9- # types: [opened, synchronize]
10- # branches: [Automatic_version_update_dependabot] # make sure this matches your actual branch name
11- check_suite :
12- types : [completed]
13- workflow_dispatch :
6+ pull_request :
7+ types : [opened, synchronize]
8+ branches : [Automatic_version_update_dependabot] # make sure this matches your actual branch name
9+
1410
1511permissions :
1612 contents : write
@@ -26,54 +22,41 @@ jobs:
2622 echo "actor: ${{ github.actor }}"
2723 echo "pr title: ${{ github.event.pull_request.title }}"
2824 echo "github event_name: ${{ github.event_name }}"
29- echo "github event_suite conlusion: ${{ github.event.check_suite.conclusion }}"
3025 echo "target branch: ${{ github.event.pull_request.base.ref }}"
3126 echo "source branch: ${{ github.event.pull_request.head.ref }}"
32- echo "Check Suite ID: ${{ github.event.check_suite.id }}"
33- echo "Conclusion: ${{ github.event.check_suite.conclusion }}"
34- echo "Target Branch: ${{ github.event.check_suite.pull_requests[0].base.ref }}"
35- echo "PR Number: ${{ github.event.check_suite.pull_requests[0].number }}"
27+ echo "PR Number: ${{ github.event.pull_request.number }}"
3628
3729 - name : Dump event payload
3830 run : |
3931 echo "==== EVENT NAME ===="
4032 echo "${{ github.event_name }}"
41- echo "==== RAW CHECK_SUITE PAYLOAD ===="
42- echo '${{ toJson(github.event.check_suite) }}'
43- echo "==== PRs in this check suite ===="
44- echo '${{ toJson(github.event.check_suite.pull_requests) }}'
33+ echo "==== RAW PULL_REQUEST PAYLOAD ===="
34+ echo '${{ toJson(github.event.pull_request) }}'
4535
46-
36+ # Branch rules ensure doesnt auto merge if shouldnt
4737 auto-merge :
4838 runs-on : ubuntu-latest
49- # if: github.event.check_suite.pull_requests[0].base.ref == 'main'
50- # if dependabot and checks ran
51- # if: (github.event_name != 'check_suite' || github.event.check_suite.conclusion == 'success')
52- # qqqq put back in later if: (github.actor == 'dependabot[bot]' || github.event_name == 'workflow_dispatch')&& (github.event_name != 'check_suite' || github.event.check_suite.conclusion == 'success')
53-
54-
55- # qqqq add in after testing && github.actor == 'dependabot[bot]'
56- if : github.event.check_suite.conclusion == 'success' && github.event.check_suite.pull_requests[0].base.ref == 'Automatic_version_update_dependabot'
39+ # qqqq add in after testing if: github.actor == 'dependabot[bot]'
5740 steps :
5841 - name : Checkout the repository
59- uses : actions/checkout@v3
42+ uses : actions/checkout@v4
43+
44+ # - name: Set up GitHub CLI
45+ # run: |
46+ # # Install GitHub CLI (gh)
47+ # sudo apt-get update
48+ # sudo apt-get install gh
6049
6150 - name : Set up GitHub CLI
62- run : |
63- # Install GitHub CLI (gh)
64- sudo apt-get update
65- sudo apt-get install gh
51+ uses : github/gh-cli@v2
6652
6753 - name : extract update type
6854 id : extract
6955 env :
7056 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7157 run : |
7258 echo "get pr number"
73- pr_number=${{ github.event.check_suite.pull_requests[0].number }}
74- echo "PR title: $pr_number"
75- # pr_title="${{ github.event.pull_request.title }}"
76- pr_title=$(gh pr view "$pr_number" --json title --jq .title)
59+ pr_title=${{ github.event.pull_request.title }}
7760 echo "PR title: $pr_title"
7861 if [[ $pr_title == *"(major)"* ]]; then
7962 echo "update_type=major" >> $GITHUB_OUTPUT
@@ -83,18 +66,14 @@ jobs:
8366
8467 - name : auto-merge minor and patch updates
8568 if : steps.extract.outputs.update_type == 'minor_or_patch'
86- # auto should set the the request to merge once checks complete
87- # qqqq could squash for cleaner? --squash "${{ github.event.pull_request.html_url }}"
88- # run: gh pr merge --auto 1
89- run : gh pr merge --auto --merge ${{ github.event.check_suite.pull_requests[0].number }}
69+ run : |
70+ gh pr merge --auto --merge "${{ github.event.pull_request.number }}"
9071 env :
91- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
72+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
9273
9374 - name : auto-merge major updates
9475 if : steps.extract.outputs.update_type == 'major'
95- # auto should set the the request to merge once checks complete
96- # qqqq could squash for cleaner? --squash "${{ github.event.pull_request.html_url }}"
97- # run: gh pr merge --auto 1
98- run : gh pr merge --auto --merge ${{ github.event.check_suite.pull_requests[0].number }}
76+ run : |
77+ gh pr merge --auto --merge "${{ github.event.pull_request.number }}"
9978 env :
100- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments