Skip to content

Commit e1651d3

Browse files
committed
test
1 parent 608140c commit e1651d3

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create PR and Approve
1+
name: Create PR, Approve, and Auto-Merge
22

33
on:
44
workflow_dispatch:
@@ -9,44 +9,52 @@ on:
99
default: "dev"
1010

1111
jobs:
12-
create-pr-and-approve:
12+
create-pr-approve-automerge:
1313
runs-on: ubuntu-latest
1414

1515
permissions:
1616
contents: write
1717
pull-requests: write
1818

1919
steps:
20+
# Paso 1: Checkout del repositorio
2021
- name: Checkout Repository
2122
uses: actions/checkout@v3
2223

24+
# Paso 2: Autenticar GitHub CLI
2325
- name: Authenticate GitHub CLI
2426
run: |
2527
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
2628
29+
# Paso 3: Crear la Pull Request con una etiqueta específica
2730
- name: Create Pull Request
2831
id: create_pr
2932
run: |
3033
PR_OUTPUT=$(gh pr create \
3134
--base main \
3235
--head ${{ github.event.inputs.target_branch }} \
3336
--title "Merge ${{ github.event.inputs.target_branch }} into main" \
34-
--body "This PR was created automatically by the workflow.")
37+
--body "This PR was created automatically by the workflow." \
38+
--label automerge)
3539
echo "PR created: $PR_OUTPUT"
3640
3741
# Extraer el número del PR
3842
PR_URL=$(echo "$PR_OUTPUT" | grep -Eo 'https://[^ ]+')
3943
PR_NUMBER="${PR_URL##*/}"
4044
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
4145
42-
- name: Approve Pull Request
43-
run: |
44-
echo "Approving the PR as ${{ github.actor }}..."
45-
gh pr review ${{ env.PR_NUMBER }} --approve
46-
47-
# Paso 6: Fusionar el Pull Request
48-
- name: Merge Pull Request
46+
auto-merge:
47+
runs-on: ubuntu-latest
48+
if: github.event.pull_request.user.login == 'github-actions[bot]' && contains(github.event.pull_request.labels.*.name, 'automerge')
49+
steps:
50+
# Loguear metadata de la PR
51+
- name: Log Metadata
4952
run: |
50-
PR_NUMBER=${{ env.PR_NUMBER }}
51-
echo "Fusionando el PR #$PR_NUMBER..."
52-
gh pr merge $PR_NUMBER --merge --admin
53+
echo "PR created by: ${{ github.event.pull_request.user.login }}"
54+
echo "Labels: ${{ toJSON(github.event.pull_request.labels) }}"
55+
56+
# Habilitar Auto-Merge para PRs con la etiqueta 'automerge'
57+
- name: Enable auto-merge for PRs with 'automerge' label
58+
run: gh pr merge --auto --merge "${{ github.event.pull_request.html_url }}"
59+
env:
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)