Skip to content

Commit

Permalink
Merge pull request #11 from wp-portugal/workflows
Browse files Browse the repository at this point in the history
Usar dados do repositório no workflow
  • Loading branch information
zedejose authored Apr 16, 2024
2 parents d615e3a + 2ad9cf6 commit d25df85
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/update-build-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ on:
workflow_dispatch:

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

permissions:
contents: write
pull-requests: write

jobs:

Expand Down Expand Up @@ -104,9 +105,15 @@ jobs:
id: check_pr
run: |
BRANCH=main
RESPONSE=$(curl -X GET -H "Authorization: token $ACCESS_TOKEN" "https://api.github.com/repos/$OWNER/$REPO/pulls?head=$OWNER:trunk")
RESPONSE=$(curl -X GET -H "Authorization: token $TOKEN" "https://api.github.com/repos/$REPO/pulls?head=$OWNER:trunk")
PR_NUMBER=$(echo "$RESPONSE" | jq -r '.[].number')
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
if [ -n "$PR_NUMBER" ]; then
echo "PR number found: $PR_NUMBER"
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
else
echo "No pull request found."
fi
- name: Create new Pull Request
id: create_pr
Expand All @@ -115,8 +122,8 @@ jobs:
BRANCH=main
TITLE="Actualizar ficheiros originais em inglês"
BODY="Este pull request automático submete alterações do branch 'trunk' para o 'main'."
URL="https://api.github.com/repos/$OWNER/$REPO/pulls"
RESPONSE=$(curl -X POST -H "Authorization: token $ACCESS_TOKEN" -d "{\"title\":\"$TITLE\",\"body\":\"$BODY\",\"head\":\"trunk\",\"base\":\"$BRANCH\"}" $URL)
URL="https://api.github.com/repos/$REPO/pulls"
RESPONSE=$(curl -X POST -H "Authorization: token $TOKEN" -d "{\"title\":\"$TITLE\",\"body\":\"$BODY\",\"head\":\"trunk\",\"base\":\"$BRANCH\"}" $URL)
echo $RESPONSE
- name: Steps debug info
Expand Down

0 comments on commit d25df85

Please sign in to comment.