From 1db189779aeff5a509b2757c07d3d47bf9e6f648 Mon Sep 17 00:00:00 2001 From: Luis Bocanegra Date: Wed, 15 Jan 2025 07:25:31 -0600 Subject: [PATCH] ci: oops --- .github/workflows/merge-translations.yml | 27 ++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/.github/workflows/merge-translations.yml b/.github/workflows/merge-translations.yml index 9aca2fe..a363291 100644 --- a/.github/workflows/merge-translations.yml +++ b/.github/workflows/merge-translations.yml @@ -6,6 +6,12 @@ on: permissions: contents: write pull-requests: write + checks: read + statuses: read + + # private repos + # actions: read + # repository-projects: read name: action-merge-translations @@ -22,10 +28,17 @@ jobs: - name: Install gettext run: sudo apt-get install gettext + + - name: Set vars + run: | + echo "BRANCH=action-merge-translations" >> $GITHUB_ENV + echo "TITLE='Merge translations'" >> $GITHUB_ENV + echo "BODY='This PR was created by GitHub Actions'" >> $GITHUB_ENV - name: Branch run: | - git checkout -b action-merge-translations + git branch -D "${{ env.BRANCH }}" || true + git checkout -b "${{ env.BRANCH }}" - name: Merge translations run: python ./kpac i18n @@ -48,12 +61,18 @@ jobs: git config --global user.name "github-actions" git config --global user.email "github-actions@github.com" git add . - git commit -m "Merge translations" - git push origin action-merge-translations -f + git commit -m "${{ env.TITLE }}" + git push origin "${{ env.BRANCH }}" -f - name: Create Pull Request if: steps.check_changes.outputs.is_changed == 'true' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh pr edit ${{ env.BRANCH_NAME }} -b '${{ env.PR_BODY }}' -t '${{ env.PR_TITLE }}' && gh pr reopen ${{ env.BRANCH_NAME }} || gh pr create --fill -B main -H ${{ env.BRANCH_NAME }} --title "Merge translations" --body "This PR was created by GitHub Actions" + PR_URL="$(gh pr list --head "${{ env.BRANCH }}" --state open --json url --jq .[].url)" + if [[ -n "${PR_URL}" ]]; then + echo "PR already exists -> ${PR_URL}" + gh pr edit "${{ env.BRANCH }}" -t "${{ env.TITLE }}" -b "${{ env.BODY }}" + else + gh pr create -B main -H "${{ env.BRANCH }}" -t "${{ env.TITLE }}" -b "${{ env.BODY }}" + fi