sync_pytorch_canary #69109
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: sync_pytorch_canary | |
on: | |
schedule: | |
# Every 15 minutes | |
- cron: "*/15 * * * *" | |
# Have the ability to trigger this job manually through the API | |
workflow_dispatch: | |
jobs: | |
sync-pytorch: | |
strategy: | |
matrix: | |
ref: ["viable/strict"] | |
runs-on: ubuntu-20.04 | |
env: | |
PYTORCH_REF: ${{ matrix.ref }} | |
steps: | |
- name: Set up SSH | |
env: | |
PYTORCH_CANARY_SSH_PRIVATE_KEY: ${{ secrets.PYTORCH_CANARY_SSH_PRIVATE_KEY }} | |
run: | | |
set -eu | |
mkdir -p ~/.ssh | |
echo "$PYTORCH_CANARY_SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
- name: Clone pytorch | |
uses: actions/checkout@v2 | |
with: | |
repository: 'pytorch/pytorch' | |
ref: ${{ matrix.ref }} | |
submodules: 'recursive' | |
path: 'pytorch' | |
fetch-depth: 0 # pushing requires nonshallow checkout | |
- name: Mirror push to pytorch/pytorch-canary | |
run: | | |
set -eu | |
export GIT_SSH_COMMAND="ssh -v -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no" | |
cd pytorch | |
# This was previously just a git push --mirror from a bare pytorch/pytorch repo, but that ran into issues as | |
# pytorch/pytorch has too many branches. We could go with a solution was derived from a StackOverflow: | |
# https://stackoverflow.com/questions/54828301/git-error-when-pushing-remote-failed-to-report-status | |
# that would look like | |
# git gc | |
# git push --tags [email protected]:pytorch/pytorch-canary.git | |
# git branch -a --format "%(refname)" | xargs -i bash -c "git symbolic-ref HEAD {} && git push [email protected]:pytorch/pytorch-canary" | |
# OR we could just settle with pushing the default branch. So we'll do that instead. | |
git push -f [email protected]:pytorch/pytorch-canary "${PYTORCH_REF}" |