From 729fb88fa4e675c0ef1a342cf669c1ced78da404 Mon Sep 17 00:00:00 2001 From: Luong Nguyen Thanh Date: Sat, 15 Jun 2024 21:20:29 +0200 Subject: [PATCH] propose change for the workflow --- .github/workflows/create_pr_on_pr.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create_pr_on_pr.yml b/.github/workflows/create_pr_on_pr.yml index a6eee046..0fbd9013 100644 --- a/.github/workflows/create_pr_on_pr.yml +++ b/.github/workflows/create_pr_on_pr.yml @@ -42,8 +42,20 @@ jobs: fi git push origin "${TRANSLATION_BRANCH}" + # Check if a PR already exists for this branch + PR_EXISTS=$(gh pr list --head "${TRANSLATION_BRANCH}" --state open --json number --jq length) + if [ "$PR_EXISTS" -eq 0 ]; then + PR_URL=$(gh pr create --base main --head "$TRANSLATION_BRANCH" --title "Handbook ${VERSION_SUFFIX/_en/} $lang" --body "Automated pull request for $lang handbook version ${VERSION_SUFFIX/_en/}") + PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$') + + else + # Get the PR number for the translation branch - PR_NUMBER=$(gh pr list --base main --json number --jq ".[] | select(.headRefName == \"$TRANSLATION_BRANCH\") | .number") + PR_NUMBER=$(gh pr list --base main --json number --jq ".[] | select(.headRefName == \"$TRANSLATION_BRANCH\") | .number") + + fi + + echo "Pull Request Number: $PR_NUMBER" # Get the date of the latest commit on the translation branch latest_commit_date=$(git show -s --format=%ci ${TRANSLATION_BRANCH})