Skip to content

Commit

Permalink
Merge pull request #13020 from ethereum/patch-workflow
Browse files Browse the repository at this point in the history
fix: workflow skips dev/staging/master branches
  • Loading branch information
minimalsm authored May 28, 2024
2 parents 899bacc + 6484c57 commit 5678325
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions .github/workflows/non-english-warning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,31 @@ on:
- "!src/intl/en/**"

jobs:
check_branch_name:
check_and_label:
runs-on: ubuntu-latest
steps:
- name: Exit early if branch name contains 'crowdin'
- name: Exit early if branch name contains 'crowdin' or is 'dev', 'staging', or 'master'
id: check_branch
run: |
if [[ "${{ github.head_ref }}" == *crowdin* ]]; then
echo "Branch name contains 'crowdin', stopping workflow"
exit 1
if [[ "${{ github.head_ref }}" == *crowdin* ]] ||
[[ "${{ github.ref }}" == 'refs/heads/dev' ]] ||
[[ "${{ github.ref }}" == 'refs/heads/staging' ]] ||
[[ "${{ github.ref }}" == 'refs/heads/master' ]]
then
echo "Branch name contains 'crowdin' or is 'dev', 'staging', or 'master', stopping workflow"
echo "::set-output name=skip::true"
exit 0
else
echo "::set-output name=skip::false"
fi
check_changes:
needs: check_branch_name
runs-on: ubuntu-latest
outputs:
all_changes_include_href: ${{ steps.check.outputs.all_changes_include_href }}
steps:
- name: Checkout code
if: steps.check_branch.outputs.skip == 'false'
uses: actions/checkout@v2

- name: Check changes
id: check
if: steps.check_branch.outputs.skip == 'false'
id: check_changes
run: |
git fetch origin ${{ github.base_ref }}
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=')
Expand All @@ -38,27 +43,24 @@ jobs:
fi
echo "::set-output name=all_changes_include_href::$ALL_CHANGES_INCLUDE_HREF"
add_label_and_comment:
needs: check_changes
runs-on: ubuntu-latest
steps:
- name: Add label and comment
if: steps.check_branch.outputs.skip == 'false'
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const prNumber = context.issue.number;
const repo = context.repo;
const prAuthor = context.payload.pull_request.user.login;
const allChangesIncludeHref = '${{ needs.check_changes.outputs.all_changes_include_href }}' === 'true';
const status = allChangesIncludeHref ? 'question ❓' : 'blocked 🛑';
const allChangesIncludeHref = '${{ steps.check_changes.outputs.all_changes_include_href }}' === 'true';
const status = allChangesIncludeHref ? 'question ❓' : 'Status: Blocked 🛑';
await github.rest.issues.addLabels({
...repo,
issue_number: prNumber,
labels: [status, 'non-crowdin translation updates']
});
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.`
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.
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.`
await github.rest.issues.createComment({
...repo,
issue_number: prNumber,
Expand All @@ -71,4 +73,4 @@ jobs:
Please post here or join [our Discord](https://ethereum.org/discord) if you have questions!
`
});
});

0 comments on commit 5678325

Please sign in to comment.