Skip to content

opt: Premium accounting with signed offset (#1019) #97

opt: Premium accounting with signed offset (#1019)

opt: Premium accounting with signed offset (#1019) #97

Workflow file for this run

name: Snapshot to private repo (cross-org)
on:
push:
branches: [main]
permissions:
contents: read
jobs:
snapshot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
submodules: false
- name: Create GitHub App token (target org)
id: tgt
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: adamavaralabs
repositories: aave-v4
- name: Build snapshot repo with gitlinks
shell: bash
run: |
set -euo pipefail
SNAP=/tmp/snap
mkdir -p "$SNAP"
cd "$SNAP"
git init
# Build exclusions for all submodule paths
RSYNC_EXCLUDES="--exclude .git --exclude .github --exclude .gitmodules"
if [[ -f "${GITHUB_WORKSPACE}/.gitmodules" ]]; then
while read -r path; do
RSYNC_EXCLUDES="$RSYNC_EXCLUDES --exclude $path"
done < <(git -C "${GITHUB_WORKSPACE}" config -f .gitmodules --get-regexp '^submodule\..*\.path' | awk '{print $2}')
fi
# Copy top-level tracked files, but NOT submodule contents or directories
eval "rsync -a --delete $RSYNC_EXCLUDES \"${GITHUB_WORKSPACE}/\" \"$SNAP/\""
# If the source has a .gitmodules, copy it verbatim
if [[ -f "${GITHUB_WORKSPACE}/.gitmodules" ]]; then
cp "${GITHUB_WORKSPACE}/.gitmodules" "$SNAP/.gitmodules"
fi
# Recreate each submodule as a real submodule gitlink pointing to the pinned commit
if [[ -f "${GITHUB_WORKSPACE}/.gitmodules" ]]; then
# Parse submodules: name, path, url
git -C "${GITHUB_WORKSPACE}" config -f .gitmodules --get-regexp '^submodule\..*\.path' | while read -r key path; do
name="${key#submodule.}"; name="${name%.path}"
url="$(git -C "${GITHUB_WORKSPACE}" config -f .gitmodules "submodule.${name}.url")"
# Pinned commit of the submodule at HEAD (gitlink object)
sha="$(git -C "${GITHUB_WORKSPACE}" ls-tree HEAD -- "$path" | awk '{print $3}')"
# Add submodule pointing at the same URL and then checkout the exact sha
git submodule add -f "$url" "$path"
# Fetch minimal data and checkout pinned sha (keeps target lightweight)
git -C "$path" fetch --depth=1 origin "$sha" || git -C "$path" fetch origin "$sha"
git -C "$path" checkout --detach "$sha"
done
fi
git add .
git -c user.name="Snapshot Bot" -c user.email="snapshot-bot@local" commit -m "Snapshot (preserve submodules) ${GITHUB_SHA}"
git branch -M main
- name: Push to target
run: |
cd /tmp/snap
git branch -M main
git remote add origin https://x-access-token:${{ steps.tgt.outputs.token }}@github.com/adamavaralabs/aave-v4.git
git push origin main --force
- name: Clean up
if: always()
run: |
rm -rf /tmp/snap