Skip to content

Enhanced Workflows for Pull Request Management #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions .github/workflows/gh-pr-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
36 changes: 31 additions & 5 deletions .github/workflows/gh-pr-merge.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Merge Squesh a Pull Request
name: Merge Pull Request

on:
workflow_dispatch:
Expand All @@ -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
Expand All @@ -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
Loading