diff --git a/.github/workflows/gh-pr-create.yml b/.github/workflows/gh-pr-create.yml index 508277b..853e20a 100644 --- a/.github/workflows/gh-pr-create.yml +++ b/.github/workflows/gh-pr-create.yml @@ -4,19 +4,19 @@ on: workflow_dispatch: inputs: repo: - description: 'Repositório de destino (ex: owner/repo-name)' + description: 'Repository (ex: owner/repo-name)' required: true source_branch: - description: 'Branch de origem (head)' + description: 'Source branch (head)' required: true target_branch: - description: 'Branch de destino (base)' + description: 'Target branch (base)' required: true title: - description: 'Título do Pull Request' + description: 'Pull Request title' required: true body: - description: 'Corpo do Pull Request' + description: 'Pull Request body' required: false permissions: @@ -31,11 +31,17 @@ jobs: env: GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | - gh pr create \ + echo "Creating Pull Request..." + # Tenta criar o PR e verifica o código de saída. + # O "GH_DEBUG=true" adiciona mais detalhes úteis em caso de falha. + if GH_DEBUG=true gh pr create \ --repo ${{ github.event.inputs.repo }} \ --title "${{ github.event.inputs.title }}" \ --body "${{ github.event.inputs.body }}" \ --head ${{ github.event.inputs.source_branch }} \ - --base ${{ github.event.inputs.target_branch }} - - echo "::notice title=Criação de PR Concluída::O Pull Request foi criado com sucesso." + --base ${{ github.event.inputs.target_branch }}; then + echo "::notice title=PR Creation Completed::The Pull Request was successfully created." + else + echo "::error title=Failed to Create PR::The command to create the Pull Request failed. Check the log for more details." + exit 1 + fi diff --git a/.github/workflows/gh-pr-merge.yml b/.github/workflows/gh-pr-merge.yml index a21a97e..ac58390 100644 --- a/.github/workflows/gh-pr-merge.yml +++ b/.github/workflows/gh-pr-merge.yml @@ -1,4 +1,4 @@ -name: Merge Squesh a Pull Request +name: Merge Pull Request on: workflow_dispatch: @@ -7,6 +7,15 @@ on: description: 'Pull Request link.' required: true default: 'https://github.com/owner/repo-name/pull/1' + merge_strategy: + description: 'Merge Strategy' + required: true + default: 'squash' + type: choice + options: + - squash + - merge + - rebase permissions: contents: write @@ -16,10 +25,27 @@ jobs: merge_pr: runs-on: ubuntu-latest steps: - - name: Merge Squash a Pull Request + - name: Merge Pull Request env: GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | - gh pr merge ${{ github.event.inputs.pr_url }} --squash - - echo "::notice title=Merge Concluído::O Pull Request foi mesclado com sucesso." + set -e + PR_URL="${{ github.event.inputs.pr_url }}" + STRATEGY="${{ github.event.inputs.merge_strategy }}" + if [ "$STRATEGY" = "squash" ]; then + MERGE_OPTION="--squash" + elif [ "$STRATEGY" = "rebase" ]; then + MERGE_OPTION="--rebase" + else + MERGE_OPTION="--merge" + fi + # ---- + echo "Tentando fazer merge do PR: $PR_URL utilizando a estratégia: $STRATEGY" + # ---- + # Doc https://cli.github.com/manual/gh_pr_merge + if gh pr merge "$PR_URL" $MERGE_OPTION; then + echo "::notice title=Merge Concluído::O Pull Request foi mesclado com sucesso usando a estratégia '$STRATEGY'." + else + echo "::error title=Erro ao Mesclar::Falha ao realizar merge do Pull Request usando a estratégia '$STRATEGY'." + exit 1 + fi