diff --git a/.github/workflows/mirror.yaml b/.github/workflows/mirror.yaml new file mode 100644 index 0000000..1cdc591 --- /dev/null +++ b/.github/workflows/mirror.yaml @@ -0,0 +1,33 @@ +name: Mirror to Public Repository +on: + push: + branches: [ jake/gha-mirror ] + +jobs: + mirror: + runs-on: ubuntu-latest + env: + ENABLE_MIRROR: ${{ secrets.ENABLE_MIRROR }} + + steps: + - name: Check if mirroring is enabled + id: mirror-enabled-check + if: ${{ env.ENABLE_MIRROR == 'true' }} + run: echo "mirror=true" >> $GITHUB_OUTPUT + + - name: Checkout private repository + uses: actions/checkout@v4 + if: steps.mirror-enabled-check.outputs.mirror == 'true' + with: + # Must be set to avoid conflicting with the subsequent push + # https://github.com/ad-m/github-push-action/issues/44#issuecomment-581706892 + fetch-depth: 0 + persist-credentials: false + + - name: Push to public repository + uses: ad-m/github-push-action@v0.8.0 + if: steps.mirror-enabled-check.outputs.mirror == 'true' + with: + github_token: ${{ secrets.PUBLIC_REPO_TOKEN }} + repository: render-oss/cli + branch: jake/gha-mirror