|
| 1 | +# This is a basic workflow to help you get started with Actions |
| 2 | + |
| 3 | +name: Rebase workflow |
| 4 | + |
| 5 | +# Controls when the workflow will run |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + prNumber: |
| 10 | + description: 'Corresponding pull request number' |
| 11 | + required: true |
| 12 | + |
| 13 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 14 | +jobs: |
| 15 | + # This workflow contains a single job called "build" |
| 16 | + build: |
| 17 | + # The type of runner that the job will run on |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 21 | + steps: |
| 22 | + - name: Generate GitHub App token |
| 23 | + id: generate_token |
| 24 | + uses: tibdex/github-app-token@v1.3.0 |
| 25 | + with: |
| 26 | + app_id: ${{ secrets.GMODNET_GITHUB_BOT_ID }} |
| 27 | + private_key: ${{ secrets.GMODNET_GITHUB_BOT_KEY }} |
| 28 | + |
| 29 | + - name: Configere Git User information |
| 30 | + run: | |
| 31 | + git config --global user.name "GmodNET GitHub Bot" |
| 32 | + git config --global user.email support@gmodnet.xyz |
| 33 | + |
| 34 | + - name: Checkout |
| 35 | + env: |
| 36 | + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} |
| 37 | + run: | |
| 38 | + gh repo clone ${{ github.repository }} ./ |
| 39 | + gh pr checkout ${{ github.event.inputs.prNumber }} |
| 40 | + |
| 41 | + - name: Extract branch name |
| 42 | + uses: nelonoel/branch-name@v1.0.1 |
| 43 | + |
| 44 | + - name: Rebase and push |
| 45 | + id: rebase_and_push |
| 46 | + continue-on-error: true |
| 47 | + run: | |
| 48 | + git rebase ${BRANCH_NAME} |
| 49 | + git push --force |
| 50 | + |
| 51 | + - name: Notify if rebase was unsuccessful |
| 52 | + if: steps.rebase_and_push.outcome == 'failure' |
| 53 | + env: |
| 54 | + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} |
| 55 | + run: gh pr comment ${{ github.event.inputs.prNumber }} --body "Automatic rebase has failed. Manual rebase is required." |
0 commit comments