Skip to content

Commit d25df85

Browse files
authored
Merge pull request #11 from wp-portugal/workflows
Usar dados do repositório no workflow
2 parents d615e3a + 2ad9cf6 commit d25df85

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Diff for: .github/workflows/update-build-files.yml

+14-7
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ on:
88
workflow_dispatch:
99

1010
env:
11-
OWNER: wp-portugal
12-
REPO: wp-portugal-i18n-build-files
13-
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # Access Token with write permissions.
11+
OWNER: ${{ github.repository_owner }}
12+
REPO: ${{ github.repository }}
13+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
1414

1515
permissions:
1616
contents: write
17+
pull-requests: write
1718

1819
jobs:
1920

@@ -104,9 +105,15 @@ jobs:
104105
id: check_pr
105106
run: |
106107
BRANCH=main
107-
RESPONSE=$(curl -X GET -H "Authorization: token $ACCESS_TOKEN" "https://api.github.com/repos/$OWNER/$REPO/pulls?head=$OWNER:trunk")
108+
RESPONSE=$(curl -X GET -H "Authorization: token $TOKEN" "https://api.github.com/repos/$REPO/pulls?head=$OWNER:trunk")
108109
PR_NUMBER=$(echo "$RESPONSE" | jq -r '.[].number')
109-
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
110+
if [ -n "$PR_NUMBER" ]; then
111+
echo "PR number found: $PR_NUMBER"
112+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
113+
else
114+
echo "No pull request found."
115+
fi
116+
110117
111118
- name: Create new Pull Request
112119
id: create_pr
@@ -115,8 +122,8 @@ jobs:
115122
BRANCH=main
116123
TITLE="Actualizar ficheiros originais em inglês"
117124
BODY="Este pull request automático submete alterações do branch 'trunk' para o 'main'."
118-
URL="https://api.github.com/repos/$OWNER/$REPO/pulls"
119-
RESPONSE=$(curl -X POST -H "Authorization: token $ACCESS_TOKEN" -d "{\"title\":\"$TITLE\",\"body\":\"$BODY\",\"head\":\"trunk\",\"base\":\"$BRANCH\"}" $URL)
125+
URL="https://api.github.com/repos/$REPO/pulls"
126+
RESPONSE=$(curl -X POST -H "Authorization: token $TOKEN" -d "{\"title\":\"$TITLE\",\"body\":\"$BODY\",\"head\":\"trunk\",\"base\":\"$BRANCH\"}" $URL)
120127
echo $RESPONSE
121128
122129
- name: Steps debug info

0 commit comments

Comments
 (0)