Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workflow skips dev/staging/master branches #13020

Merged
merged 4 commits into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!
`
});
});
Loading