diff --git a/.github/workflows/crowdin-i18n-client-ui-download.yml b/.github/workflows/crowdin-i18n-client-ui-download.yml index d53cd6df35..2063451043 100644 --- a/.github/workflows/crowdin-i18n-client-ui-download.yml +++ b/.github/workflows/crowdin-i18n-client-ui-download.yml @@ -90,6 +90,25 @@ jobs: with: github-token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }} script: | + const branchExists = await github.repos.getBranch({ + owner: 'freeCodeCamp', + repo: 'freeCodeCamp', + branch: 'i18n-sync-client' + }).catch(err => { + console.info("Branch does not exist. Likely no changes in download?"); + }); + if (!branchExists || branchExists.status !== 200) { + return; + } + const pullRequestExists = await github.pulls.list({ + owner: 'freeCodeCamp', + repo: 'freeCodeCamp', + head: 'freeCodeCamp:i18n-sync-client' + }); + if (pullRequestExists.data.length) { + console.info("It looks like a pull request already exists for this branch."); + return; + } const PR = await github.pulls.create({ owner: 'freeCodeCamp', repo: 'freeCodeCamp', @@ -97,7 +116,13 @@ jobs: base: 'main', title: 'chore(i18n,client): processed translations', body: 'This PR was opened auto-magically by Crowdin.' + }).catch(err => { + console.info("Unpredicted error occurred when trying to create the PR."); + console.error(err); }); + if (!PR || PR.status !== 201) { + return; + } const PRNumber = PR.data.number; await github.issues.addLabels({ owner: 'freeCodeCamp', diff --git a/.github/workflows/crowdin-i18n-curriculum-download.yml b/.github/workflows/crowdin-i18n-curriculum-download.yml index efaec0ad09..75f9792db8 100644 --- a/.github/workflows/crowdin-i18n-curriculum-download.yml +++ b/.github/workflows/crowdin-i18n-curriculum-download.yml @@ -91,6 +91,25 @@ jobs: with: github-token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }} script: | + const branchExists = await github.repos.getBranch({ + owner: 'freeCodeCamp', + repo: 'freeCodeCamp', + branch: 'i18n-sync-learn' + }).catch(err => { + console.info("Branch does not exist. Likely no changes in download?"); + }); + if (!branchExists || branchExists.status !== 200) { + return; + } + const pullRequestExists = await github.pulls.list({ + owner: 'freeCodeCamp', + repo: 'freeCodeCamp', + head: 'freeCodeCamp:i18n-sync-learn' + }); + if (pullRequestExists.data.length) { + console.info("It looks like a pull request already exists for this branch."); + return; + } const PR = await github.pulls.create({ owner: 'freeCodeCamp', repo: 'freeCodeCamp', @@ -98,7 +117,13 @@ jobs: base: 'main', title: 'chore(i18n,learn): processed translations', body: 'This PR was opened auto-magically by Crowdin.' + }).catch(err => { + console.info("Unpredicted error occurred when trying to create the PR."); + console.error(err); }); + if (!PR || PR.status !== 201) { + return; + } const PRNumber = PR.data.number; await github.issues.addLabels({ owner: 'freeCodeCamp', diff --git a/.github/workflows/crowdin-i18n-docs-download..yml b/.github/workflows/crowdin-i18n-docs-download..yml index 47cf8ea880..2fa68eae10 100644 --- a/.github/workflows/crowdin-i18n-docs-download..yml +++ b/.github/workflows/crowdin-i18n-docs-download..yml @@ -124,6 +124,25 @@ jobs: with: github-token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }} script: | + const branchExists = await github.repos.getBranch({ + owner: 'freeCodeCamp', + repo: 'freeCodeCamp', + branch: 'i18n-sync-docs' + }).catch(err => { + console.info("Branch does not exist. Likely no changes in download?"); + }); + if (!branchExists || branchExists.status !== 200) { + return; + } + const pullRequestExists = await github.pulls.list({ + owner: 'freeCodeCamp', + repo: 'freeCodeCamp', + head: 'freeCodeCamp:i18n-sync-docs' + }); + if (pullRequestExists.data.length) { + console.info("It looks like a pull request already exists for this branch."); + return; + } const PR = await github.pulls.create({ owner: 'freeCodeCamp', repo: 'freeCodeCamp', @@ -131,7 +150,13 @@ jobs: base: 'main', title: 'chore(i18n,docs): processed translations', body: 'This PR was opened auto-magically by Crowdin.' + }).catch(err => { + console.info("Unpredicted error occurred when trying to create the PR."); + console.error(err); }); + if (!PR || PR.status !== 201) { + return; + } const PRNumber = PR.data.number; await github.issues.addLabels({ owner: 'freeCodeCamp',