chore(deps): update dependency jsdom to v24 #42
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
name: Yarn Unlocker | |
# Short-cut for the common case of a PR having a merge conflict with only `yarn.lock`. | |
# Responds to a comment on a pull request containing "/yarn unlock" | |
# Test-merges the PR. If there's only one conflict, that being yarn.lock, | |
# it runs `yarn` (which will fix it) and pushes the merge commit. | |
on: | |
issue_comment: | |
types: [created] | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
jobs: | |
merge-yarn-lock: | |
if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/yarn unlock') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/github-script@v7 | |
id: comment | |
with: | |
script: | | |
const comment = await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Trying to merge yarn.lock... follow along at https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}` | |
}) | |
return comment.data.id | |
- uses: actions/checkout@v4 | |
with: | |
ref: refs/pull/${{ github.event.issue.number }}/head | |
fetch-depth: 0 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
cache: "yarn" | |
cache-dependency-path: "yarn.lock" | |
- run: yarn install --immutable --inline-builds | |
- id: merge | |
run: | | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git merge origin/main > ${{ runner.temp }}/merge.log || true | |
# If there are no conflicts, we're done here | |
if ! grep -q 'CONFLICT' ${{ runner.temp }}/merge.log; then | |
echo needs-merge=false >> "$GITHUB_OUTPUT" | |
exit 1 | |
fi | |
# Abort *unless* there is only one conflict, that being yarn.lock | |
if [ "$(grep -c 'CONFLICT' ${{ runner.temp }}/merge.log)" -eq 1 ] && grep -q 'Merge conflict in yarn.lock' ${{ runner.temp }}/merge.log; then | |
exit 0 | |
fi | |
echo cannot-fix=true >> "$GITHUB_OUTPUT" | |
exit 1 | |
- if: failure() && steps.merge.outputs.needs-merge == 'false' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.updateComment({ | |
comment_id: ${{ steps.comment.outputs.result }}, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'No conflicts found.' | |
}) | |
- if: failure() && steps.merge.outputs.cannot-fix == 'true' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.updateComment({ | |
comment_id: ${{ steps.comment.outputs.result }}, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Cannot fix conflicts. Please merge manually.' | |
}) | |
- run: | | |
yarn install --no-immutable | |
git add yarn.lock | |
git commit -m 'chore: merge yarn.lock' | |
git push origin HEAD | |
- uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.updateComment({ | |
comment_id: ${{ steps.comment.outputs.result }}, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Merged yarn.lock!' | |
}) | |
- if: failure() && !steps.merge.outputs.needs-merge && !steps.merge.outputs.cannot-fix | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.updateComment({ | |
comment_id: ${{ steps.comment.outputs.result }}, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Something went wrong. Please look at [the logs](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}).` | |
}) |