-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
145 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,47 @@ | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
pr: | ||
description: 'The pull request to update' | ||
required: true | ||
pull_request_target: | ||
types: [labeled] | ||
|
||
name: 'Smart master merge' | ||
name: 'Smart merge' | ||
jobs: | ||
merge: | ||
name: 'Merge master into the PR' | ||
reset: | ||
name: 'Remove the label' | ||
runs-on: ubuntu-latest | ||
if: | | ||
github.event.label.name == 'infra: pending update' | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: 'Remove the label' | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
await github.rest.issues.removeLabel({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
name: context.payload.label.name, | ||
}); | ||
generate: | ||
name: 'Generate an update changeset' | ||
runs-on: ubuntu-latest | ||
needs: reset | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: master | ||
token: ${{secrets.YARNBOT_TOKEN}} | ||
ref: ${{github.event.pull_request.head.sha}} | ||
fetch-depth: 0 | ||
|
||
- uses: ./.github/actions/prepare | ||
|
||
- name: 'Update, commit, and upload the artifacts' | ||
- name: 'Generate the changeset' | ||
run: | | ||
PR_META=$(curl https://api.github.com/repos/yarnpkg/berry/pulls/'${{github.event.inputs.pr}}') | ||
git fetch origin master | ||
PR_REPO=$(jq -r .head.repo.full_name <<< "$PR_META") | ||
PR_REF=$(jq -r .head.ref <<< "$PR_META") | ||
git config user.name "Yarn Bot" | ||
git config user.email [email protected] | ||
git remote add pr-source https://'${{secrets.YARNBOT_TOKEN}}'@github.com/"$PR_REPO".git | ||
git fetch pr-source "$PR_REF":local | ||
git checkout local | ||
if ! git merge origin/master; then | ||
if ! git merge --no-commit origin/master; then | ||
export YARN_ENABLE_IMMUTABLE_INSTALLS=0 | ||
if git diff --name-only --diff-filter=U | grep .pnp.cjs; then | ||
|
@@ -63,9 +69,58 @@ jobs: | |
git checkout --theirs packages/yarnpkg-parsers/sources/grammars/shell.js | ||
yarn grammar:shell | ||
fi | ||
git add .pnp.cjs packages/yarnpkg-pnp/sources/hook.js packages/yarnpkg-pnp/sources/esm-loader/built-loader.js packages/yarnpkg-parsers/sources/grammars/shell.js | ||
git commit -m 'Auto-merge with master' | ||
fi | ||
git push pr-source local:"$PR_REF" | ||
yarn test:lint --fix | ||
- name: Generate the artifacts | ||
run: | | ||
git config user.name "Yarn Bot" | ||
git config user.email [email protected] | ||
git diff > merge-conflict-resolution.patch | ||
- name: Store the merge conflict resolution | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: merge-conflict-resolution | ||
path: merge-conflict-resolution.patch | ||
|
||
apply: | ||
name: 'Apply the update changeset' | ||
runs-on: ubuntu-latest | ||
needs: generate | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{github.event.pull_request.head.sha}} | ||
fetch-depth: 0 | ||
|
||
- name: Retrieve the merge conflict resolution | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: merge-conflict-resolution | ||
|
||
- name: Apply the changeset | ||
env: | ||
GH_BOT_TOKEN: ${{secrets.YARNBOT_TOKEN}} | ||
GH_REPO_NAME: ${{github.event.pull_request.head.repo.full_name}} | ||
GH_HEAD_REF: ${{github.event.pull_request.head.ref}} | ||
run: | | ||
git config user.name "Yarn Bot" | ||
git config user.email [email protected] | ||
git remote add pr-source https://"${GH_BOT_TOKEN}"@github.com/"${GH_REPO_NAME}".git | ||
git fetch pr-source "$GH_HEAD_REF":local | ||
git checkout local | ||
git fetch origin master | ||
git merge --no-commit origin/master || true | ||
git add -A | ||
git apply --allow-empty merge-conflict-resolution.patch | ||
git commit --allow-empty -m 'Auto-merge with master' | ||
git push pr-source local:"$GH_HEAD_REF" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test |
c225c1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some leftover tests in here @arcanis