From aae438d6410c9351d8340c58a241f82e9a073080 Mon Sep 17 00:00:00 2001 From: ludamad Date: Mon, 5 Feb 2024 03:24:44 +0000 Subject: [PATCH] fix: for prod --- .github/workflows/mirror_noir_subrepo.yml | 29 +++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/mirror_noir_subrepo.yml b/.github/workflows/mirror_noir_subrepo.yml index 7b0e5a79985..9dc20b3cdb1 100644 --- a/.github/workflows/mirror_noir_subrepo.yml +++ b/.github/workflows/mirror_noir_subrepo.yml @@ -10,10 +10,10 @@ concurrency: on: push: branches: - - ad/chore/better-noir-sync - # paths: - # - 'noir/**' - # - '!noir/.gitrepo' + - master + paths: + - 'noir/**' + - '!noir/.gitrepo' jobs: mirror_repo: @@ -43,10 +43,10 @@ jobs: - name: Push to branch run: | set -xue # print commands - # Enable gh executable. - export GH_TOKEN="${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}" + # Enable gh executable. We spread out the API requests between the github actions bot token, and aztecbot + export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" SUBREPO_PATH=noir - BRANCH=aztec2-packages + BRANCH=aztec-packages # identify ourselves, needed to commit git config --global user.name AztecBot git config --global user.email tech@aztecprotocol.com @@ -60,13 +60,16 @@ jobs: # Reset our branch to our expected target git push origin $BRANCH --force cd .. - # Get the last merged PR + # Get the last sync PR's last commit state LAST_MERGED_PR_HASH=`gh pr list --repo=noir-lang/noir --state merged --head aztec-packages --json headRefOid --jq=.[0].headRefOid` + # Use a commit heuristic where we look at when .gitrepo first started to look at that commit state (through a push) COMMIT_HEURISTIC=$(git log -p -S"$LAST_MERGED_PR_HASH" --reverse --source -- noir/.gitrepo | grep -m 1 '^commit' | awk '{print $2}' || true) if [[ " $COMMIT_HEURISTIC" = "" ]] ; then + # It it fails, just use our gitrepo parent commit (last time we pushed or pulled) COMMIT_HEURISTIC=$BASE_AZTEC_COMMIT fi - MESSAGE=$(git log --pretty=format:"%s" $COMMIT_HEURISTIC..HEAD -- noir/ ':!noir/.gitrepo' | grep -v 'git subrepo || true') + # Create a filtered git log for release-please changelog / metadata + MESSAGE=$(git log --pretty=format:"%s" $COMMIT_HEURISTIC..HEAD -- noir/ ':!noir/.gitrepo' | grep -v 'git subrepo' || true) # Fix Aztec PR links MESSAGE=$(echo "$MESSAGE" | sed -E 's/\(#([0-9]+)\)/(https:\/\/github.com\/AztecProtocol\/aztec-packages\/pull\/\1)/g') git commit --allow-empty -m"chore: Sync to noir-lang/noir" -m"$MESSAGE" @@ -84,9 +87,11 @@ jobs: PR_BODY="""BEGIN_COMMIT_OVERRIDE $MESSAGE END_COMMIT_OVERRIDE""" - PR_URL=$(gh pr list --repo noir-lang/noir --head aztec2-packages --json url --jq ".[0].url") + PR_URL=$(gh pr list --repo noir-lang/noir --head aztec-packages --json url --jq ".[0].url") + # for cross-opening PR in noir repo, we use aztecbot's token + export GH_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} if [[ "$PR_URL" == "" ]]; then - gh pr create --repo noir-lang/noir --title "feat: Sync from aztec-packages" --body "$PR_BODY" --base master --head aztec2-packages + gh pr create --repo noir-lang/noir --title "feat: Sync from aztec-packages" --body "$PR_BODY" --base master --head aztec-packages else gh pr edit "$PR_URL" --body "$PR_BODY" - fi \ No newline at end of file + fi