-
Notifications
You must be signed in to change notification settings - Fork 310
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
2 changed files
with
104 additions
and
1 deletion.
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
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,91 @@ | ||
name: Find Recent Closed PR | ||
|
||
on: | ||
push: | ||
branches: [ ad/chore/better-noir-sync ] | ||
|
||
jobs: | ||
find-pr: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Get commit hash of last aztec2-packages squash-merge | ||
id: last_merge_hash | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
// NOTE: more robust heuristic needed if aztecbot opens different kinds of PRs | ||
const response = await github.rest.search.commits({ | ||
q: 'author:AztecBot committer:web-flow repo:noir-lang/noir sort:committer-date' | ||
}); | ||
console.log(response.data.items); | ||
return response.data.items[0].sha; | ||
- name: Check for open PRs on noir-lang/noir | ||
id: sync_pr_exists | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} | ||
script: | | ||
const { data: pullRequests } = await github.rest.pulls.list({ | ||
owner: 'noir-lang', | ||
repo: 'noir', | ||
state: 'open', | ||
head: 'noir-lang:aztec2-packages', | ||
per_page: 1 | ||
}); | ||
console.log({pullRequests}) | ||
return pullRequests.length > 0; | ||
- name: Checkout noir repo | ||
uses: actions/checkout@v3 | ||
if: steps.sync_pr_exists.outputs.result == 'false' | ||
with: | ||
fetch-depth: 0 | ||
repository: noir-lang/noir | ||
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} | ||
- name: Reset noir-lang/noir branch if no PRs | ||
if: steps.sync_pr_exists.outputs.result == 'false' | ||
run: | | ||
set -x # print commands | ||
git checkout aztec2-packages || git checkout -b aztec2-packages | ||
git reset --hard ${{ steps.last_merge_hash.outputs.result }} | ||
git push origin aztec2-packages --force | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} | ||
|
||
# We push using git subrepo (https://github.com/ingydotnet/git-subrepo) | ||
# with some logic to recover from squashed parent commits | ||
# We push to subrepo, commit to master. The commit is needed | ||
# to continue to replay. If we still hit issues such as this | ||
# action failing due to upstream changes, a manual resolution | ||
# PR with ./scripts/git_subrepo.sh pull will be needed. | ||
- name: Push to branch | ||
run: | | ||
SUBREPO_PATH=noir | ||
BRANCH=aztec2-packages | ||
# identify ourselves, needed to commit | ||
git config --global user.name AztecBot | ||
git config --global user.email [email protected] | ||
if [ ${{steps.sync_pr_exists.outputs.result}} = "false" ] ; then | ||
echo "Resetting noir push base to PR base as we have a new PR." | ||
git config --file=noir/.gitrepo subrepo.commit ${{steps.last_merge_hash.outputs.result}} | ||
fi | ||
if ./scripts/git_subrepo.sh push $SUBREPO_PATH --branch=$BRANCH; then | ||
git commit --amend -m "$(git log -1 --pretty=%B) [skip ci]" | ||
git push | ||
else | ||
echo "Problems syncing noir. We may need to pull the subrepo." | ||
exit 1 | ||
fi | ||
# - name: Create PR for Aztec Branch | ||
# if: steps.sync_pr_exists.outputs.result == 'false' | ||
# uses: repo-sync/pull-request@v2 | ||
# with: | ||
# github_token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} | ||
# pr_title: 'feat: Sync commits from `aztec2-packages`' | ||
# pr_body: 'Development from [aztec2-packages](https://github.com/AztecProtocol/aztec2-packages).' | ||
# destination_branch: 'master' | ||
# source_branch: 'aztec2-packages' |