Skip to content

Commit 5678325

Browse files
authored
Merge pull request #13020 from ethereum/patch-workflow
fix: workflow skips dev/staging/master branches
2 parents 899bacc + 6484c57 commit 5678325

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

.github/workflows/non-english-warning.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,31 @@ on:
88
- "!src/intl/en/**"
99

1010
jobs:
11-
check_branch_name:
11+
check_and_label:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- name: Exit early if branch name contains 'crowdin'
14+
- name: Exit early if branch name contains 'crowdin' or is 'dev', 'staging', or 'master'
15+
id: check_branch
1516
run: |
16-
if [[ "${{ github.head_ref }}" == *crowdin* ]]; then
17-
echo "Branch name contains 'crowdin', stopping workflow"
18-
exit 1
17+
if [[ "${{ github.head_ref }}" == *crowdin* ]] ||
18+
[[ "${{ github.ref }}" == 'refs/heads/dev' ]] ||
19+
[[ "${{ github.ref }}" == 'refs/heads/staging' ]] ||
20+
[[ "${{ github.ref }}" == 'refs/heads/master' ]]
21+
then
22+
echo "Branch name contains 'crowdin' or is 'dev', 'staging', or 'master', stopping workflow"
23+
echo "::set-output name=skip::true"
24+
exit 0
25+
else
26+
echo "::set-output name=skip::false"
1927
fi
2028
21-
check_changes:
22-
needs: check_branch_name
23-
runs-on: ubuntu-latest
24-
outputs:
25-
all_changes_include_href: ${{ steps.check.outputs.all_changes_include_href }}
26-
steps:
2729
- name: Checkout code
30+
if: steps.check_branch.outputs.skip == 'false'
2831
uses: actions/checkout@v2
32+
2933
- name: Check changes
30-
id: check
34+
if: steps.check_branch.outputs.skip == 'false'
35+
id: check_changes
3136
run: |
3237
git fetch origin ${{ github.base_ref }}
3338
DIFF=$(git diff --no-ext-diff --unified=0 origin/${{ github.base_ref }}..${{ github.head_ref }} -- 'public/content/translations/**/*.md' 'src/intl/**/*.json' '!src/intl/en/**' | grep -E -v '^[-+]href=')
@@ -38,27 +43,24 @@ jobs:
3843
fi
3944
echo "::set-output name=all_changes_include_href::$ALL_CHANGES_INCLUDE_HREF"
4045
41-
add_label_and_comment:
42-
needs: check_changes
43-
runs-on: ubuntu-latest
44-
steps:
4546
- name: Add label and comment
47+
if: steps.check_branch.outputs.skip == 'false'
4648
uses: actions/github-script@v5
4749
with:
4850
github-token: ${{secrets.GITHUB_TOKEN}}
4951
script: |
5052
const prNumber = context.issue.number;
5153
const repo = context.repo;
5254
const prAuthor = context.payload.pull_request.user.login;
53-
const allChangesIncludeHref = '${{ needs.check_changes.outputs.all_changes_include_href }}' === 'true';
54-
const status = allChangesIncludeHref ? 'question ❓' : 'blocked 🛑';
55+
const allChangesIncludeHref = '${{ steps.check_changes.outputs.all_changes_include_href }}' === 'true';
56+
const status = allChangesIncludeHref ? 'question ❓' : 'Status: Blocked 🛑';
5557
await github.rest.issues.addLabels({
5658
...repo,
5759
issue_number: prNumber,
5860
labels: [status, 'non-crowdin translation updates']
5961
});
6062
const commentWithoutHrefs = `This pull request contains changes to non-English content, which must also be handled through the Crowdin platform instead of only on GitHub.`
61-
const commentWithHrefs = `This pull request contains changes to non-English content files, which may also need to be handled through the Crowdin platform instead of only on GitHub.
63+
const commentWithHrefs = `This pull request contains changes to non-English content files, which may also need to be handled through the Crowdin platform instead of only on GitHub.`
6264
await github.rest.issues.createComment({
6365
...repo,
6466
issue_number: prNumber,
@@ -71,4 +73,4 @@ jobs:
7173
7274
Please post here or join [our Discord](https://ethereum.org/discord) if you have questions!
7375
`
74-
});
76+
});

0 commit comments

Comments
 (0)