Sync rustwright-cloud changes to rustwright (#27) #17
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync rustwright changes to rustwright-cloud | |
| on: | |
| pull_request_target: | |
| types: [closed] | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| sync: | |
| if: >- | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event.pull_request.merged == true && | |
| !contains(join(github.event.pull_request.labels.*.name, ','), 'sync') && | |
| !startsWith(github.event.pull_request.head.ref, 'repo-sync/')) | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| steps: | |
| - name: Checkout main | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Sync shared files to rustwright-cloud | |
| id: file-sync | |
| uses: Skyvern-AI/repo-file-sync-action@590c4ddbe1d7b5c4ca1e4b4edc85c7f919b6c26a # main | |
| with: | |
| GH_PAT: ${{ secrets.RUSTWRIGHT_SYNC_GH_PAT }} | |
| GIT_EMAIL: ${{ github.event.pull_request.user.id && format('{0}+{1}@users.noreply.github.com', github.event.pull_request.user.id, github.event.pull_request.user.login) || format('{0}@users.noreply.github.com', github.actor) }} | |
| GIT_USERNAME: ${{ github.event.pull_request.user.login || github.actor }} | |
| PR_LABELS: sync | |
| BRANCH_NAME: repo-sync/rustwright-${{ github.event.pull_request.number || github.run_id }} | |
| PR_BODY: ${{ github.event.pull_request.html_url || 'Manual sync from rustwright' }} | |
| PR_TITLE: "Sync rustwright changes to rustwright-cloud (#${{ github.event.pull_request.number || github.run_id }})" | |
| - name: Link the rustwright-cloud PR | |
| if: github.event_name == 'pull_request_target' && steps.file-sync.outputs.pull_request_urls | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| env: | |
| PR_URLS: ${{ steps.file-sync.outputs.pull_request_urls }} | |
| with: | |
| script: | | |
| let urls; | |
| try { | |
| urls = JSON.parse(process.env.PR_URLS); | |
| } catch { | |
| urls = [process.env.PR_URLS].filter(Boolean); | |
| } | |
| if (urls.length) { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| body: urls.map((url) => `Synced to rustwright-cloud: ${url}`).join('\n'), | |
| }); | |
| } |