1- name : Mirror to Public Repository
1+ name : copybara-push
2+
23on :
34 push :
4- branches : [ main ]
5+ branches : [main]
56
67jobs :
7- mirror :
8+ copy :
9+ if : ${{ github.repository == 'renderinc/skills' }}
810 runs-on : ubuntu-latest
9- env :
10- ENABLE_MIRROR : ${{ secrets.ENABLE_MIRROR }}
11-
1211 steps :
13- - name : Checkout private repository
14- uses : actions/checkout@v4
15- if : ${{ env.ENABLE_MIRROR == 'true' }}
12+ - name : Checkout repository
13+ uses : actions/checkout@v6
14+ - uses : actions/setup-java@v5
1615 with :
17- # Must be set to avoid conflicting with the subsequent push
18- # https://github.com/ad-m/github-push-action/issues/44#issuecomment-581706892
19- fetch-depth : 0
20- persist-credentials : false
21-
22- - name : Push to public repository
23- uses : ad-m/github-push-action@v0.8.0
24- if : ${{ env.ENABLE_MIRROR == 'true' }}
16+ distribution : oracle
17+ java-version : 21
18+ - name : Generate an app token for render-oss
19+ id : generate-token-oss
20+ uses : actions/create-github-app-token@v2
21+ with :
22+ app-id : ${{ vars.APP_ID }}
23+ private-key : ${{ secrets.APP_KEY }}
24+ owner : render-oss
25+ repositories : skills
26+ - name : Generate an app token for renderinc
27+ id : generate-token-renderinc
28+ uses : actions/create-github-app-token@v2
2529 with :
26- github_token : ${{ secrets.PUBLIC_REPO_TOKEN }}
27- repository : renderinc/skills
28- branch : main
29- force : true
30+ app-id : ${{ vars.APP_ID }}
31+ private-key : ${{ secrets.APP_KEY }}
32+ owner : renderinc
33+ repositories : skills
34+ - name : Get GitHub App User ID
35+ id : get-user-id
36+ env :
37+ GH_TOKEN : ${{ steps.generate-token-renderinc.outputs.token }}
38+ APP_SLUG : ${{ steps.generate-token-renderinc.outputs.app-slug }}
39+ run : echo "user-id=$(gh api "/users/$APP_SLUG[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
40+ - name : Set up credentials
41+ env :
42+ RENDERINC_TOKEN : ${{ steps.generate-token-renderinc.outputs.token }}
43+ RENDER_OSS_TOKEN : ${{ steps.generate-token-oss.outputs.token }}
44+ APP_SLUG : ${{ steps.generate-token-oss.outputs.app-slug }}
45+ USER_ID : ${{ steps.get-user-id.outputs.user-id }}
46+ run : |
47+ echo "https://$USER:$RENDERINC_TOKEN@api.github.com" > ~/.git-credentials
48+ echo "https://$USER:$RENDERINC_TOKEN@github.com" >> ~/.git-credentials
49+ git config --global user.name "$APP_SLUG[bot]"
50+ git config --global user.email "$USER_ID+$APP_SLUG[bot]@users.noreply.github.com"
51+ git config --global url."https://$USER:${RENDERINC_TOKEN}@github.com/renderinc".insteadOf "git@github.com:renderinc"
52+ git config --global url."https://$USER:${RENDERINC_TOKEN}@github.com/renderinc".insteadOf "https://github.com/renderinc"
53+ git config --global url."https://$USER:${RENDER_OSS_TOKEN}@github.com/render-oss".insteadOf "git@github.com:render-oss"
54+ git config --global url."https://$USER:${RENDER_OSS_TOKEN}@github.com/render-oss".insteadOf "https://github.com/render-oss"
55+ - name : Set up copybara
56+ run : |
57+ wget https://github.com/google/copybara/releases/download/v20251215/copybara_deploy.jar
58+ java -jar copybara_deploy.jar version
59+ java -jar copybara_deploy.jar validate copy.bara.sky
60+ - name : Run workflow
61+ env :
62+ RENDER_OSS_TOKEN : ${{ steps.generate-token-oss.outputs.token }}
63+ run : |
64+ java -jar copybara_deploy.jar copy.bara.sky push \
65+ --git-destination-url "https://$USER:$RENDER_OSS_TOKEN@github.com/render-oss/skills.git"
0 commit comments