|
| 1 | +--- |
| 2 | +####################################### |
| 3 | +####################################### |
| 4 | +## Dependabot automerge dependencies ## |
| 5 | +####################################### |
| 6 | +####################################### |
| 7 | + |
| 8 | +# |
| 9 | +# Documentation: |
| 10 | +# https://medium.com/@toufik.airane/automerge-github-dependabot-alerts-with-github-actions-7cd6f5763750 |
| 11 | +# |
| 12 | + |
| 13 | +###################### |
| 14 | +# name of the action # |
| 15 | +###################### |
| 16 | +name: automerge on pull request |
| 17 | + |
| 18 | +############### |
| 19 | +# When to run # |
| 20 | +############### |
| 21 | +on: [ pull_request ] |
| 22 | + |
| 23 | +################# |
| 24 | +# Start the job # |
| 25 | +################# |
| 26 | +jobs: |
| 27 | + automerge: |
| 28 | + name: automerge dependabot |
| 29 | + runs-on: ubuntu-latest |
| 30 | + if: github.actor == 'dependabot[bot]' && github.repository == 'megalinter/megalinter' |
| 31 | + steps: |
| 32 | + - name: Wait for CI/CT/CD to succeed |
| 33 | + uses: fountainhead/[email protected] |
| 34 | + id: wait-for-build |
| 35 | + with: |
| 36 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + checkName: Tests + Deploy Docker Image - DEV |
| 38 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 39 | + |
| 40 | + - name: Wait for CI/CT/CD to succeed pt2 |
| 41 | + uses: fountainhead/[email protected] |
| 42 | + id: wait-for-ci |
| 43 | + with: |
| 44 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + checkName: MegaLinter |
| 46 | + ref: ${{ github.event.pull_request.head.sha || github.sha }} |
| 47 | + |
| 48 | + - name: merge |
| 49 | + if: steps.wait-for-build.outputs.conclusion == 'success' || steps.wait-for-build.outputs.conclusion == 'skipped' && steps.wait-for-ci.outputs.conclusion == 'success' |
| 50 | + uses: actions/github-script@v6 |
| 51 | + with: |
| 52 | + script: | |
| 53 | + github.pulls.createReview({ |
| 54 | + owner: context.payload.repository.owner.login, |
| 55 | + repo: context.payload.repository.name, |
| 56 | + pull_number: context.payload.pull_request.number, |
| 57 | + event: 'APPROVE' |
| 58 | + }) |
| 59 | + github.pulls.merge({ |
| 60 | + owner: context.payload.repository.owner.login, |
| 61 | + repo: context.payload.repository.name, |
| 62 | + pull_number: context.payload.pull_request.number |
| 63 | + }) |
0 commit comments