forked from yarnpkg/berry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements smart merge v2 (yarnpkg#4177)
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
on: | ||
workflow_run: | ||
workflows: ['Smart merge: Generate'] | ||
types: | ||
- completed | ||
|
||
name: 'Smart merge: Apply' | ||
jobs: | ||
apply: | ||
name: 'Apply the update changeset' | ||
runs-on: ubuntu-latest | ||
if: | | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{github.event.workflow_run.head_sha}} | ||
|
||
- name: 'Download the artifacts' | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
const fs = require(`fs`); | ||
const artifacts = await github.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: ${{github.event.workflow_run.id}}, | ||
}); | ||
const matchArtifact = artifacts.data.artifacts.filter(artifact => { | ||
return artifact.name == `pr`; | ||
})[0]; | ||
const download = await github.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: `zip`, | ||
}); | ||
fs.writeFileSync(`${{github.workspace}}/pr.zip`, Buffer.from(download.data)); | ||
- name: Unpack the artifacts | ||
run: unzip pr.zip | ||
|
||
- name: Apply the changeset | ||
run: | | ||
PR_META=$(curl https://api.github.com/repos/yarnpkg/berry/pulls/'${{github.event.inputs.pr}}') | ||
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 --depth=1 pr-source "$PR_REF":local | ||
git checkout local | ||
git merge --no-commit origin/master || true | ||
git apply pr/update.patch | ||
git commit -m 'Auto-merge with master' | ||
git push pr-source local:"$PR_REF" |
File renamed without changes.
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,23 @@ | ||
on: | ||
pull_request_target: | ||
types: [labeled] | ||
|
||
name: 'Smart merge: Reset' | ||
jobs: | ||
generate: | ||
name: 'Remove the label' | ||
runs-on: ubuntu-latest | ||
if: | | ||
github.event.label.name == 'infra: pending update' | ||
steps: | ||
- name: 'Remove the label' | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
await github.rest.issues.removeLabel({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.pull_request.number, | ||
name: `infra: pending update`, | ||
}); |