Skip to content

Mirror Repositories #99

Mirror Repositories

Mirror Repositories #99

Workflow file for this run

# We push using git subrepo (https://github.com/ingydotnet/git-subrepo)
# with some logic to recover from squashed parent commits
# We first identify ourselves, needed to commit.
# Then 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: Mirror Repositories
on:
schedule:
# Run the workflow every night at 2:00 AM UTC.
- cron: "0 2 * * *"
jobs:
mirror-to-barretenberg-repo:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
- name: Push to barretenberg repo
run: |
SUBREPO_PATH=barretenberg
git config --global user.name AztecBot
git config --global user.email [email protected]
if ./scripts/git_subrepo.sh push $SUBREPO_PATH --branch=master; then
git fetch # in case a commit came after this
git rebase origin/master
git commit --amend -m "$(git log -1 --pretty=%B) [skip ci]"
git push
fi
mirror-to-aztec-nr-repo:
runs-on: ubuntu-latest
# Force sequential.
needs: mirror-to-barretenberg-repo
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
- name: Push to aztec-nr repo
run: |
SUBREPO_PATH=noir-projects/aztec-nr
git config --global user.name AztecBot
git config --global user.email [email protected]
monorepo_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
# list all aztec-packages tags, take the "highest" version
monorepo_tag="$(git tag --list aztec-packages-v* | sort --version-sort | tail -1)"
monorepo_protocol_circuits_path="noir-projects/noir-protocol-circuits"
# take all Nargo.toml files that reference noir-protocol-circuits
nargo_files="$(find $SUBREPO_PATH -name 'Nargo.toml' | xargs grep --files-with-matches 'noir-protocol-circuits')"
# match lines like this:
# protocol_types = { path = "../../noir-protocol-circuits/crates/types" }
# and replace with
# protocol_types = { git="https://github.com/aztecprotocol/aztec-packages", tag="aztec-packages-v0.16.9", directory="noir-projects/noir-protocol-circuits/crates/types" }
for nargo_file in $nargo_files; do
sed --regexp-extended --in-place \
"s;path\s*=\s*\".*noir-protocol-circuits(.*)\";git=\"$monorepo_url\", tag=\"$monorepo_tag\", directory=\"$monorepo_protocol_circuits_path\1\";" \
$nargo_file
done
git commit --all --message "chore: replace relative paths to noir-protocol-circuits"
if ./scripts/git_subrepo.sh push $SUBREPO_PATH --branch=master; then
git fetch # in case a commit came after this
git rebase origin/master
# restore old files
for nargo_file in $nargo_files; do
git restore --source=origin/master -- $nargo_file
done
git commit --all --amend -m "$(git log -1 --pretty=%B) [skip ci]"
git push
fi