0

I have a public repo on Github that I would like to clone.

My goal is to setup a Github action that, once every month, it will clone this repo and upload any new changes from the public repo (hosted on Github) to my private repo.

This is my yml file so far:

name: Clone Repo Copy

on:
  schedule:    
      - cron: "0 0 1 * *"
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          repository: aws/aws-sdk-java-archetype
          token: ${{ secrets.GITHUBPAT }}
      - uses: actions/checkout@v2
      - run: |
          git config user.name github-actions
          git config user.email github-actions@github.com
          git add .
          git commit -m "generated"
          git push

(my secrets.GITHUBPAT is my Github Personal Access Token which has access to everything for debugging purposes)

However, as expected, it didnt work, here are my logs: https://pastebin.com/tHLP0rn5 (Edited to remove username and repo) How could I make GitHub Actions clone a public repo and push it to my private repo?

Robert
  • 113
  • 6

2 Answers2

0

You don't need to add and commit anything if you just want to push the changes to the mirror repo.

In that case use git remote add mirror https://url.to.your.private.repo and then push git push mirror branchname the commits that don't exist on the source branch will be synced to the remote.

This assumes the mirror is an exact copy and people aren't pushing changes to that repo as well, in which case the process would be a bit harder.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
0

You could use an action like Git Sync Action which works even with independent/non-forked repos.

Florian G.
  • 36
  • 3