From 0be1fb6897b32a32af30fbc12d4155041dd3842c Mon Sep 17 00:00:00 2001 From: Jonny Gerig Meyer Date: Tue, 31 Jan 2023 17:33:07 -0500 Subject: [PATCH 1/3] Add shadow repo workflow --- .github/workflows/shadow-repo.yml | 72 +++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/shadow-repo.yml diff --git a/.github/workflows/shadow-repo.yml b/.github/workflows/shadow-repo.yml new file mode 100644 index 000000000..6c0818787 --- /dev/null +++ b/.github/workflows/shadow-repo.yml @@ -0,0 +1,72 @@ +name: Sync with shadow repo + +on: + push: + create: + delete: + pull_request: + types: [opened] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + +jobs: + sync-branch: + name: Create/delete shadow branch + runs-on: ubuntu-latest + if: github.event.ref_type == 'branch' + steps: + - name: Clone shadow repo + uses: actions/checkout@v3 + with: + repository: ${{ secrets.SHADOW_OWNER }}/${{ secrets.SHADOW_REPO }} + ssh-key: ${{ secrets.SHADOW_REPO_PRIVATE_KEY }} + ref: main + - name: Create branch on shadow repo + if: github.event_name == 'create' + run: git push origin main:${{ github.event.ref }} + - name: Delete branch on shadow repo + if: github.event_name == 'delete' + run: git push origin --delete ${{ github.event.ref }} + + push-branch: + name: Push to shadow branch + runs-on: ubuntu-latest + if: github.event_name == 'push' + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version-file: .nvmrc + cache: yarn + - run: yarn install + - run: yarn build-prod + - name: Clone shadow repo + uses: actions/checkout@v3 + with: + repository: ${{ secrets.SHADOW_OWNER }}/${{ secrets.SHADOW_REPO }} + ssh-key: ${{ secrets.SHADOW_REPO_PRIVATE_KEY }} + ref: ${{ github.ref_name }} + path: shadow-repo + - name: Push to shadow branch + run: | + cd shadow-repo + rm -rf ./* + cp -rT ../_site . + git config user.name github-actions + git config user.email github-actions@github.com + git add -A + git commit --allow-empty -m "Update from https://github.com/${{ github.repository }}/commit/${{ github.sha }}" + git push origin + + diff-link: + name: Create comment to diff link + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.action == 'opened' + steps: + - uses: peter-evans/create-or-update-comment@v2 + with: + issue-number: ${{ github.event.number }} + body: | + View diff of compiled files (may take a few minutes): https://github.com/${{ secrets.SHADOW_OWNER }}/${{ secrets.SHADOW_REPO }}/compare/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.ref }} From 71dd6d201e4b9ebe45452c7d4118415f98f563db Mon Sep 17 00:00:00 2001 From: Jonny Gerig Meyer Date: Tue, 31 Jan 2023 17:42:59 -0500 Subject: [PATCH 2/3] Update .github/workflows/shadow-repo.yml Co-authored-by: Ed Rivas --- .github/workflows/shadow-repo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shadow-repo.yml b/.github/workflows/shadow-repo.yml index 6c0818787..0cf6dbd82 100644 --- a/.github/workflows/shadow-repo.yml +++ b/.github/workflows/shadow-repo.yml @@ -20,7 +20,7 @@ jobs: - name: Clone shadow repo uses: actions/checkout@v3 with: - repository: ${{ secrets.SHADOW_OWNER }}/${{ secrets.SHADOW_REPO }} + repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }} ssh-key: ${{ secrets.SHADOW_REPO_PRIVATE_KEY }} ref: main - name: Create branch on shadow repo From ebe86c191a90fd56b508e6937aaf463f55c72392 Mon Sep 17 00:00:00 2001 From: Jonny Gerig Meyer Date: Tue, 31 Jan 2023 17:45:08 -0500 Subject: [PATCH 3/3] fix remaining references --- .github/workflows/shadow-repo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/shadow-repo.yml b/.github/workflows/shadow-repo.yml index 0cf6dbd82..6ad52bd45 100644 --- a/.github/workflows/shadow-repo.yml +++ b/.github/workflows/shadow-repo.yml @@ -45,7 +45,7 @@ jobs: - name: Clone shadow repo uses: actions/checkout@v3 with: - repository: ${{ secrets.SHADOW_OWNER }}/${{ secrets.SHADOW_REPO }} + repository: ${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }} ssh-key: ${{ secrets.SHADOW_REPO_PRIVATE_KEY }} ref: ${{ github.ref_name }} path: shadow-repo @@ -69,4 +69,4 @@ jobs: with: issue-number: ${{ github.event.number }} body: | - View diff of compiled files (may take a few minutes): https://github.com/${{ secrets.SHADOW_OWNER }}/${{ secrets.SHADOW_REPO }}/compare/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.ref }} + View diff of compiled files (may take a few minutes): https://github.com/${{ vars.SHADOW_OWNER }}/${{ vars.SHADOW_REPO }}/compare/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.ref }}