|
| 1 | +name: copybara-pr |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + copy: |
| 9 | + if: ${{ github.repository == 'render-oss/cli' }} |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout repository |
| 13 | + uses: actions/checkout@v6 |
| 14 | + - uses: actions/setup-java@v5 |
| 15 | + with: |
| 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: cli |
| 26 | + - name: Generate an app token for renderinc |
| 27 | + id: generate-token-renderinc |
| 28 | + uses: actions/create-github-app-token@v2 |
| 29 | + with: |
| 30 | + app-id: ${{ vars.APP_ID }} |
| 31 | + private-key: ${{ secrets.APP_KEY }} |
| 32 | + owner: renderinc |
| 33 | + repositories: cli |
| 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 | + RENDERINC_TOKEN: ${{ steps.generate-token-renderinc.outputs.token }} |
| 63 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 64 | + run: | |
| 65 | + java -jar copybara_deploy.jar copy.bara.sky pr $PR_NUMBER \ |
| 66 | + --git-destination-url "https://$USER:$RENDERINC_TOKEN@github.com/renderinc/cli.git" |
0 commit comments