Skip to content

Commit

Permalink
Re-add migrator-comment and major-version-check workflows (#11921)
Browse files Browse the repository at this point in the history
Re-add the following workflows:
- #8733
- #8997
  • Loading branch information
aaronccasanova authored Apr 20, 2024
1 parent b71eff5 commit a1e4f88
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/major-version-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Major version in changeset

on:
pull_request:
branches:
- main
types:
- labeled
- unlabeled
- opened
- synchronize
- reopened

jobs:
check-changesets:
if: |
!contains(github.event.pull_request.labels.*.name, '🤖Skip Major Check')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Fetch all branches
run: git fetch --all

- name: Checkout the feature branch
run: git checkout "$GITHUB_HEAD_REF" --

- name: Check major versions in changeset entries
run: |
commits="origin/$GITHUB_BASE_REF...origin/$GITHUB_HEAD_REF"
changeset_files=$(git diff --name-only --diff-filter=d "$commits" -- ".changeset/*.md")
if [[ -z "$changeset_files" ]]; then
echo "No changeset files detected"
exit 0
fi
if ! echo "$changeset_files" | xargs grep -qE "^\s*[\"'].*?[\"']\s*:\s*major\s*$"; then
echo "No major version upgrade detected"
exit 0
else
echo "This PR contains a major version upgrade which is only used for breaking changes."
echo "If you are sure you want to perform this action, please add the '🤖Skip Major Check' label"
exit 1
fi
52 changes: 52 additions & 0 deletions .github/workflows/migrator-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Migrator comment in diff

on:
pull_request:
types:
- labeled
- unlabeled
- opened
- synchronize
- reopened

env:
COMMENT: 'generated by polaris-migrator DO NOT COPY'

jobs:
check-diff:
if: |
!contains(github.event.pull_request.labels.*.name, '🤖Skip Comment Check')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Fetch all branches
run: git fetch --all

- name: Checkout the feature branch
run: git checkout "$GITHUB_HEAD_REF" --

- name: Check for generic migrator comment in diff
run: |
commits="origin/$GITHUB_BASE_REF...origin/$GITHUB_HEAD_REF"
files=$(git diff --name-only --diff-filter=d "$commits" -- "*.scss")
if [ -n "$files" ]; then
echo "SCSS files where modified."
echo "$files"
else
echo "No SCSS files where modified."
exit 0
fi
filesWithComment=$(git diff --unified=0 --diff-filter=d "$commits" -- $(echo $files) | grep "^\+.*$COMMENT" || true)
if [ -n "$filesWithComment" ]; then
echo "A migrator comment '$COMMENT' was added to a SCSS file in this PR."
echo "Please provide a description for any Stylelint disable comments."
echo "If this is not applicable, you can add the '🤖Skip Comment Check' label to this PR."
exit 1
else
echo "All good, no migrator comments were added."
fi

0 comments on commit a1e4f88

Please sign in to comment.