19
19
echo "Validating if ${{ github.actor }} is a Code Owner..."
20
20
21
21
# Lista de Code Owners
22
- CODEOWNERS=("paula-encinar")
22
+ CODEOWNERS=("paula-encinar" "antonio-ailabs" "marcos-rodriguez-insud" )
23
23
24
24
# Convertir el actor actual a minúsculas para comparación
25
25
GITHUB_ACTOR_LOWER=$(echo "${{ github.actor }}" | tr '[:upper:]' '[:lower:]')
@@ -35,32 +35,26 @@ jobs:
35
35
needs : validate-codeowner
36
36
runs-on : ubuntu-latest
37
37
38
- steps :
39
- # Paso 2: Seleccionar el Token del Code Owner basado en github.actor
40
- - name : Select Code Owner Token
41
- id : select-token
42
- run : |
43
- echo "Selecting token for ${{ github.actor }}..."
44
- TOKEN_ENV_NAME=$(echo "${{ github.actor }}" | tr '[:lower:]' '[:upper:]' | tr '-' '_' )_TOKEN
45
- echo "TOKEN_ENV_NAME=${TOKEN_ENV_NAME}" >> $GITHUB_ENV
46
- echo "Selected token environment variable: $TOKEN_ENV_NAME"
38
+ permissions :
39
+ contents : write
40
+ pull-requests : write
47
41
48
- # Paso 3: Autenticar GitHub CLI con el Token seleccionado
49
- - name : Authenticate GitHub CLI with Selected Token
42
+ steps :
43
+ # Paso 2: Autenticar GitHub CLI con el GITHUB_TOKEN
44
+ - name : Authenticate GitHub CLI with GITHUB_TOKEN
50
45
run : |
51
- echo "Authenticating GitHub CLI with the token for ${{ github.actor }}..."
52
- gh auth logout || true
53
- echo "${{ secrets[env.TOKEN_ENV_NAME] }}" | gh auth login --with-token
46
+ echo "Authenticating GitHub CLI with GITHUB_TOKEN..."
47
+ echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
54
48
55
- # Paso 4 : Crear la Pull Request
49
+ # Paso 3 : Crear la Pull Request con el GITHUB_TOKEN
56
50
- name : Create Pull Request
57
51
id : create_pr
58
52
run : |
59
53
PR_OUTPUT=$(gh pr create \
60
54
--base main \
61
55
--head ${{ github.event.inputs.target_branch }} \
62
56
--title "Merge ${{ github.event.inputs.target_branch }} into main" \
63
- --body "This PR was created and approved by ${{ github.actor }} using their own PAT ." \
57
+ --body "This PR was created automatically using GITHUB_TOKEN ." \
64
58
--label automerge)
65
59
echo "PR created: $PR_OUTPUT"
66
60
79
73
runs-on : ubuntu-latest
80
74
81
75
steps :
82
- # Paso 5: Aprueba la PR con el mismo Token seleccionado
76
+ # Paso 4: Seleccionar el Token del Code Owner basado en github.actor
77
+ - name : Select Code Owner Token
78
+ id : select-token
79
+ run : |
80
+ echo "Selecting token for ${{ github.actor }}..."
81
+ TOKEN_ENV_NAME=$(echo "${{ github.actor }}" | tr '[:lower:]' '[:upper:]' | tr '-' '_' )_TOKEN
82
+ echo "TOKEN_ENV_NAME=${TOKEN_ENV_NAME}" >> $GITHUB_ENV
83
+ echo "Selected token environment variable: $TOKEN_ENV_NAME"
84
+
85
+ # Paso 5: Autenticar GitHub CLI con el Token seleccionado
86
+ - name : Authenticate GitHub CLI with Selected Token
87
+ run : |
88
+ echo "Authenticating GitHub CLI with the token for ${{ github.actor }}..."
89
+ gh auth logout || true
90
+ echo "${{ secrets[env.TOKEN_ENV_NAME] }}" | gh auth login --with-token
91
+
92
+ # Paso 6: Aprobar la PR con el Token del Code Owner
83
93
- name : Approve Pull Request with Selected Token
84
94
run : |
85
95
echo "Approving the PR #${{ needs.create-pr.outputs.pr_number }} with the token for ${{ github.actor }}..."
89
99
needs : [create-pr, approve-pr]
90
100
runs-on : ubuntu-latest
91
101
102
+ permissions :
103
+ contents : write
104
+ pull-requests : write
105
+
92
106
steps :
93
107
# Habilitar Auto-Merge para la PR con etiqueta 'automerge'
94
108
- name : Enable Auto-Merge
0 commit comments