|
| 1 | +name: "/git command" |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [ git-command ] |
| 6 | + |
| 7 | +concurrency: |
| 8 | + group: ${{ github.workflow }}-${{ github.event.client_payload.github.payload.issue.number }}-${{ github.event.client_payload.slash_command.command }}-${{ github.event.client_payload.slash_command.args.unnamed.arg1 || github.event.client_payload.slash_command.args.all }} |
| 9 | + |
| 10 | +jobs: |
| 11 | + merge: |
| 12 | + if: ${{ github.event.client_payload.slash_command.args.unnamed.arg1 == 'merge' }} |
| 13 | + runs-on: ubuntu-latest |
| 14 | + timeout-minutes: 10 |
| 15 | + steps: |
| 16 | + |
| 17 | + |
| 18 | + - name: Add Workflow link to command comment |
| 19 | + uses: peter-evans/create-or-update-comment@v4 |
| 20 | + with: |
| 21 | + token: ${{ secrets.GIT_PAT }} |
| 22 | + repository: ${{ github.event.client_payload.github.payload.repository.full_name }} |
| 23 | + comment-id: ${{ github.event.client_payload.github.payload.comment.id }} |
| 24 | + body: | |
| 25 | + > [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
| 26 | +
|
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + token: ${{ secrets.GIT_PAT }} |
| 31 | + repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} |
| 32 | + ref: ${{ github.event.client_payload.pull_request.head.ref }} |
| 33 | + |
| 34 | + - name: Checkout Actions Hub |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + token: ${{ secrets.GIT_PAT }} |
| 38 | + repository: HumanSignal/actions-hub |
| 39 | + path: ./.github/actions-hub |
| 40 | + |
| 41 | + - name: Git Configure |
| 42 | + uses: ./.github/actions-hub/actions/git-configure |
| 43 | + with: |
| 44 | + username: ${{ github.event.client_payload.github.actor }} |
| 45 | + |
| 46 | + - name: Git Merge |
| 47 | + id: merge |
| 48 | + uses: ./.github/actions-hub/actions/git-merge |
| 49 | + with: |
| 50 | + base_branch: ${{ github.event.client_payload.slash_command.args.unnamed.arg2 || github.event.client_payload.pull_request.base.ref }} |
| 51 | + our_files: "" |
| 52 | + |
| 53 | + - name: Git Push |
| 54 | + if: steps.merge.outputs.result == 'true' |
| 55 | + uses: ./.github/actions-hub/actions/git-push |
| 56 | + |
| 57 | + - name: Add reaction to command comment |
| 58 | + uses: peter-evans/create-or-update-comment@v4 |
| 59 | + if: always() |
| 60 | + with: |
| 61 | + token: ${{ secrets.GIT_PAT }} |
| 62 | + repository: ${{ github.event.client_payload.github.payload.repository.full_name }} |
| 63 | + comment-id: ${{ github.event.client_payload.github.payload.comment.id }} |
| 64 | + body: | |
| 65 | + > ${{ steps.merge.outputs.message || '**Error**: Workflow failed' }} |
| 66 | + reactions: ${{ steps.merge.outputs.reaction || '-1' }} |
| 67 | + |
| 68 | + help: |
| 69 | + if: ${{ github.event.client_payload.slash_command.args.unnamed.arg1 == 'help' || !contains(fromJson('["merge"]'), github.event.client_payload.slash_command.args.unnamed.arg1) }} |
| 70 | + runs-on: ubuntu-latest |
| 71 | + timeout-minutes: 1 |
| 72 | + steps: |
| 73 | + - name: Update comment |
| 74 | + uses: peter-evans/create-or-update-comment@v4 |
| 75 | + with: |
| 76 | + token: ${{ secrets.GIT_PAT }} |
| 77 | + repository: ${{ github.event.client_payload.github.payload.repository.full_name }} |
| 78 | + comment-id: ${{ github.event.client_payload.github.payload.comment.id }} |
| 79 | + body: | |
| 80 | + > Command | Description |
| 81 | + > --- | --- |
| 82 | + > /git merge `branch` | Merge branch `branch` into current branch |
| 83 | + reactions: hooray |
0 commit comments