From 38eec637a090002d902278478a0d9fc18f5e4b13 Mon Sep 17 00:00:00 2001 From: Ales Tsurko Date: Thu, 2 May 2024 13:50:29 +0300 Subject: [PATCH 01/28] Remove unrelated jobs --- .github/chain-endpoints.md | 10 --- .github/issue_template.md | 86 ------------------------ .github/workflows/auto-approve.yml | 16 ----- .github/workflows/auto-merge.yml | 16 ----- .github/workflows/chain-endpoints.yml | 32 --------- .github/workflows/lock.yml | 23 ------- .github/workflows/push-master.yml | 95 --------------------------- 7 files changed, 278 deletions(-) delete mode 100644 .github/chain-endpoints.md delete mode 100644 .github/issue_template.md delete mode 100644 .github/workflows/auto-approve.yml delete mode 100644 .github/workflows/auto-merge.yml delete mode 100644 .github/workflows/chain-endpoints.yml delete mode 100644 .github/workflows/lock.yml delete mode 100644 .github/workflows/push-master.yml diff --git a/.github/chain-endpoints.md b/.github/chain-endpoints.md deleted file mode 100644 index 0d5da1e4a5b4..000000000000 --- a/.github/chain-endpoints.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: Unavailable chain endpoints {{ date | date('ddd, MMM D YYYY, h:mm:ss a') }} -labels: ['ci'] ---- - -cc @polkadot-js/notifications - -Some configured endpoints are not available. - -Check the nightly cron output (or via `yarn ci:chainEndpoints` locally) and disable the chains (either with `isDisabled` or `isUnreachable`) until the issue is resolved. The output as found from the test includes: diff --git a/.github/issue_template.md b/.github/issue_template.md deleted file mode 100644 index 50f40146e7ed..000000000000 --- a/.github/issue_template.md +++ /dev/null @@ -1,86 +0,0 @@ - - - -* **I'm submitting a ...** - - - - - [ ] Bug report - - [ ] Feature request - - [ ] Support request - - [ ] Other - - -* **What is the current behavior and expected behavior?** - - - - -* **What is the motivation for changing the behavior?** - - - - -* **Please tell us about your environment:** - - - - - Version: - - Environment: - - - [ ] Node.js - - [ ] Browser - - [ ] Other (limited support for other environments) - - - Language: - - - [ ] JavaScript - - [ ] TypeScript (include tsc --version) - - [ ] Other diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml deleted file mode 100644 index ba1cf70adb67..000000000000 --- a/.github/workflows/auto-approve.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: bot - -on: - pull_request: - types: [labeled] - -jobs: - approve: - if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)" - runs-on: ubuntu-latest - steps: - - uses: jacogr/action-approve@795afd1dd096a2071d7ec98740661af4e853b7da - with: - authors: jacogr - labels: -auto - token: ${{ secrets.GH_PAT_BOT }} diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml deleted file mode 100644 index dd61ab9903b5..000000000000 --- a/.github/workflows/auto-merge.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: bot - -on: - pull_request: - types: [labeled] - -jobs: - merge: - runs-on: ubuntu-latest - steps: - - uses: jacogr/action-merge@d2d64b4545acd93b0a9575177d3d215ae3f92029 - with: - checks: pr (build:code),pr (build:i18n),pr (build:electron),pr (lint),pr (test) - labels: -auto - strategy: squash - token: ${{ secrets.GH_PAT_BOT }} diff --git a/.github/workflows/chain-endpoints.yml b/.github/workflows/chain-endpoints.yml deleted file mode 100644 index bfbfa93167f1..000000000000 --- a/.github/workflows/chain-endpoints.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Chain endpoints -on: - schedule: - # twice daily (mornings/afternoons, the latter being busy) - # - cron: '50 0/12 * * *' - # once daily (early mornings, 02:50 GMT, generally not busy) - - cron: '50 2 * * *' - -jobs: - endpoints: - if: github.repository == 'polkadot-js/apps' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 'lts/*' - - name: check - env: - CI_LOG: 123 - run: | - yarn install --immutable | grep -v 'YN0013' - yarn ci:chainEndpoints - - - name: issue - if: ${{ failure() }} - uses: JasonEtco/create-an-issue@e27dddc79c92bc6e4562f268fffa5ed752639abd - env: - GITHUB_TOKEN: ${{ secrets.GH_PAT_BOT }} - with: - filename: .github/chain-endpoints.md - update_existing: true diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml deleted file mode 100644 index 5f7400fabfbf..000000000000 --- a/.github/workflows/lock.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: 'Lock Threads' - -on: - schedule: - - cron: '15 2/3 * * *' - -jobs: - lock: - runs-on: ubuntu-latest - steps: - - uses: dessant/lock-threads@c1b35aecc5cdb1a34539d14196df55838bb2f836 - with: - github-token: ${{ secrets.GH_PAT_BOT }} - issue-inactive-days: '7' - issue-comment: > - This thread has been automatically locked since there has not been - any recent activity after it was closed. Please open a new issue - if you think you have a related problem or query. - pr-inactive-days: '2' - pr-comment: > - This pull request has been automatically locked since there - has not been any recent activity after it was closed. - Please open a new issue for related bugs. diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml deleted file mode 100644 index bbd3ae9cd03a..000000000000 --- a/.github/workflows/push-master.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: Master -on: - push: - branches: - - master - -jobs: - # publish to gh-pages (& IPFS when a release is detected) - www: - if: "! startsWith(github.event.head_commit.message, '[CI Skip]')" - strategy: - matrix: - step: ['build:release:www'] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - token: ${{ secrets.GH_PAT_BOT }} - - uses: actions/setup-node@v3 - with: - node-version: 'lts/*' - - name: ${{ matrix.step }} - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} - CRUST_SEEDS: ${{ secrets.CRUST_SEEDS }} - GH_PAGES_SRC: packages/apps/build - GH_PAT: ${{ secrets.GH_PAT_BOT }} - GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT_BOT }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - PINATA_API_KEY: ${{ secrets.PINATA_API_KEY }} - PINATA_SECRET_KEY: ${{ secrets.PINATA_SECRET_KEY }} - run: | - yarn install --immutable - yarn ${{ matrix.step }} - - # only run on "CI skip", i.e. when the actual version has been bumped to release/stable - docker: - if: "startsWith(github.event.head_commit.message, '[CI Skip] release/stable')" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 'lts/*' - - name: docker - env: - DOCKER_PASS: ${{ secrets.DOCKER_PASS }} - run: | - ./docker/build.sh - - # only run on "CI skip", i.e. when the actual version has been bumped to release/stable - electron: - if: "startsWith(github.event.head_commit.message, '[CI Skip] release/stable')" - strategy: - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - with: - token: ${{ secrets.GH_PAT_BOT }} - - uses: actions/setup-node@v3 - with: - node-version: 'lts/*' - - name: Prepare for app notarization (macOS) - if: startsWith(matrix.os, 'macos') - # Import Apple API key for app notarization on macOS - run: | - mkdir -p ~/private_keys/ - echo '${{ secrets.API_KEY }}' > ~/private_keys/AuthKey_${{ secrets.API_KEY_ID }}.p8 - - name: Build/release Electron app - uses: samuelmeuli/action-electron-builder@v1 - with: - # Base64-encoded code signing certificate for macOS - mac_certs: ${{ secrets.MAC_CERTS }} - # Password for decrypting `mac_certs` - mac_certs_password: ${{ secrets.MAC_CERTS_PASSWORD }} - # Base64-encoded code signing certificate for Windows - windows_certs: ${{ secrets.WINDOWS_CERTS }} - # Password for decrypting `windows_certs` - windows_certs_password: ${{ secrets.WINDOWS_CERTS_PASSWORD }} - # GitHub token, automatically provided to the action - # (No need to define this secret in the repo settings) - github_token: ${{ secrets.GITHUB_TOKEN }} - args: '--project packages/apps-electron' - build_script_name: build:release:electron - # If the commit is tagged with a version (e.g. "v1.0.0"), - # release the app after building - release: ${{ startsWith(github.ref, 'refs/tags/v') }} - env: - # macOS notarization API key - API_KEY_ID: ${{ secrets.API_KEY_ID }} - API_KEY_ISSUER_ID: ${{ secrets.API_KEY_ISSUER_ID }} From 88f18703f3f90ea6e41980b33f90c1cd0218619c Mon Sep 17 00:00:00 2001 From: Ales Tsurko Date: Thu, 2 May 2024 14:03:54 +0300 Subject: [PATCH 02/28] Configure upstream sync --- .github/workflows/auto-approve.yml | 16 +++++ .github/workflows/auto-merge.yml | 16 +++++ .github/workflows/chain-endpoints.yml | 32 +++++++++ .github/workflows/lock.yml | 23 +++++++ .github/workflows/push-master.yml | 95 +++++++++++++++++++++++++++ .github/workflows/sync-upstream.yml | 53 +++++++++++++++ 6 files changed, 235 insertions(+) create mode 100644 .github/workflows/auto-approve.yml create mode 100644 .github/workflows/auto-merge.yml create mode 100644 .github/workflows/chain-endpoints.yml create mode 100644 .github/workflows/lock.yml create mode 100644 .github/workflows/push-master.yml create mode 100644 .github/workflows/sync-upstream.yml diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml new file mode 100644 index 000000000000..ba1cf70adb67 --- /dev/null +++ b/.github/workflows/auto-approve.yml @@ -0,0 +1,16 @@ +name: bot + +on: + pull_request: + types: [labeled] + +jobs: + approve: + if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository)" + runs-on: ubuntu-latest + steps: + - uses: jacogr/action-approve@795afd1dd096a2071d7ec98740661af4e853b7da + with: + authors: jacogr + labels: -auto + token: ${{ secrets.GH_PAT_BOT }} diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml new file mode 100644 index 000000000000..dd61ab9903b5 --- /dev/null +++ b/.github/workflows/auto-merge.yml @@ -0,0 +1,16 @@ +name: bot + +on: + pull_request: + types: [labeled] + +jobs: + merge: + runs-on: ubuntu-latest + steps: + - uses: jacogr/action-merge@d2d64b4545acd93b0a9575177d3d215ae3f92029 + with: + checks: pr (build:code),pr (build:i18n),pr (build:electron),pr (lint),pr (test) + labels: -auto + strategy: squash + token: ${{ secrets.GH_PAT_BOT }} diff --git a/.github/workflows/chain-endpoints.yml b/.github/workflows/chain-endpoints.yml new file mode 100644 index 000000000000..bfbfa93167f1 --- /dev/null +++ b/.github/workflows/chain-endpoints.yml @@ -0,0 +1,32 @@ +name: Chain endpoints +on: + schedule: + # twice daily (mornings/afternoons, the latter being busy) + # - cron: '50 0/12 * * *' + # once daily (early mornings, 02:50 GMT, generally not busy) + - cron: '50 2 * * *' + +jobs: + endpoints: + if: github.repository == 'polkadot-js/apps' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + - name: check + env: + CI_LOG: 123 + run: | + yarn install --immutable | grep -v 'YN0013' + yarn ci:chainEndpoints + + - name: issue + if: ${{ failure() }} + uses: JasonEtco/create-an-issue@e27dddc79c92bc6e4562f268fffa5ed752639abd + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT_BOT }} + with: + filename: .github/chain-endpoints.md + update_existing: true diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml new file mode 100644 index 000000000000..5f7400fabfbf --- /dev/null +++ b/.github/workflows/lock.yml @@ -0,0 +1,23 @@ +name: 'Lock Threads' + +on: + schedule: + - cron: '15 2/3 * * *' + +jobs: + lock: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@c1b35aecc5cdb1a34539d14196df55838bb2f836 + with: + github-token: ${{ secrets.GH_PAT_BOT }} + issue-inactive-days: '7' + issue-comment: > + This thread has been automatically locked since there has not been + any recent activity after it was closed. Please open a new issue + if you think you have a related problem or query. + pr-inactive-days: '2' + pr-comment: > + This pull request has been automatically locked since there + has not been any recent activity after it was closed. + Please open a new issue for related bugs. diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml new file mode 100644 index 000000000000..bbd3ae9cd03a --- /dev/null +++ b/.github/workflows/push-master.yml @@ -0,0 +1,95 @@ +name: Master +on: + push: + branches: + - master + +jobs: + # publish to gh-pages (& IPFS when a release is detected) + www: + if: "! startsWith(github.event.head_commit.message, '[CI Skip]')" + strategy: + matrix: + step: ['build:release:www'] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GH_PAT_BOT }} + - uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + - name: ${{ matrix.step }} + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} + CRUST_SEEDS: ${{ secrets.CRUST_SEEDS }} + GH_PAGES_SRC: packages/apps/build + GH_PAT: ${{ secrets.GH_PAT_BOT }} + GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT_BOT }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + PINATA_API_KEY: ${{ secrets.PINATA_API_KEY }} + PINATA_SECRET_KEY: ${{ secrets.PINATA_SECRET_KEY }} + run: | + yarn install --immutable + yarn ${{ matrix.step }} + + # only run on "CI skip", i.e. when the actual version has been bumped to release/stable + docker: + if: "startsWith(github.event.head_commit.message, '[CI Skip] release/stable')" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + - name: docker + env: + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + run: | + ./docker/build.sh + + # only run on "CI skip", i.e. when the actual version has been bumped to release/stable + electron: + if: "startsWith(github.event.head_commit.message, '[CI Skip] release/stable')" + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.GH_PAT_BOT }} + - uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + - name: Prepare for app notarization (macOS) + if: startsWith(matrix.os, 'macos') + # Import Apple API key for app notarization on macOS + run: | + mkdir -p ~/private_keys/ + echo '${{ secrets.API_KEY }}' > ~/private_keys/AuthKey_${{ secrets.API_KEY_ID }}.p8 + - name: Build/release Electron app + uses: samuelmeuli/action-electron-builder@v1 + with: + # Base64-encoded code signing certificate for macOS + mac_certs: ${{ secrets.MAC_CERTS }} + # Password for decrypting `mac_certs` + mac_certs_password: ${{ secrets.MAC_CERTS_PASSWORD }} + # Base64-encoded code signing certificate for Windows + windows_certs: ${{ secrets.WINDOWS_CERTS }} + # Password for decrypting `windows_certs` + windows_certs_password: ${{ secrets.WINDOWS_CERTS_PASSWORD }} + # GitHub token, automatically provided to the action + # (No need to define this secret in the repo settings) + github_token: ${{ secrets.GITHUB_TOKEN }} + args: '--project packages/apps-electron' + build_script_name: build:release:electron + # If the commit is tagged with a version (e.g. "v1.0.0"), + # release the app after building + release: ${{ startsWith(github.ref, 'refs/tags/v') }} + env: + # macOS notarization API key + API_KEY_ID: ${{ secrets.API_KEY_ID }} + API_KEY_ISSUER_ID: ${{ secrets.API_KEY_ISSUER_ID }} diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml new file mode 100644 index 000000000000..ef239677b797 --- /dev/null +++ b/.github/workflows/sync-upstream.yml @@ -0,0 +1,53 @@ +name: 'Upstream Sync' + +on: + pull_request: + + schedule: + - cron: '0 7 * * 1' + # scheduled at 07:00 every Monday + + workflow_dispatch: # click the button on Github repo! + inputs: + sync_test_mode: # Adds a boolean option that appears during manual workflow run for easy test mode config + description: 'Fork Sync Test Mode' + type: boolean + default: false + +jobs: + sync_latest_from_upstream: + runs-on: ubuntu-latest + name: Sync latest commits from upstream repo + + steps: + - name: Checkout target repo + uses: actions/checkout@v3 + with: + # optional: set the branch to checkout, + ref: upstream + token: ${{ secrets.GITHUB_TOKEN }} + # persist-credentials: false + + - name: Sync upstream changes + id: sync + uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1 + with: + target_sync_branch: upstream + # target_repo_token: ${{ secrets.GITHUB_TOKEN }} + upstream_sync_branch: master + upstream_sync_repo: polkadot-js/apps + + # Set test_mode true during manual dispatch to run tests instead of the true action!! + test_mode: ${{ inputs.sync_test_mode }} + + # Display a sample message based on the sync output var 'has_new_commits' + - name: New commits found + if: steps.sync.outputs.has_new_commits == 'true' + run: echo "New commits were found to sync." + + - name: No new commits + if: steps.sync.outputs.has_new_commits == 'false' + run: echo "There were no new commits." + + - name: Show value of 'has_new_commits' + run: echo ${{ steps.sync.outputs.has_new_commits }} From 9e191c4268b9c4a5784239a95f00c47acdf3e03d Mon Sep 17 00:00:00 2001 From: Ales Tsurko Date: Mon, 12 Aug 2024 14:48:51 +0300 Subject: [PATCH 03/28] Add write permission to the sync workflow --- .github/workflows/sync-upstream.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index ef239677b797..6b295eca95c6 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -1,5 +1,8 @@ name: 'Upstream Sync' +permissions: + contents: write + on: pull_request: From 35662343a875891a69a35c446e3b3fe37ed16713 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Tue, 20 Aug 2024 18:06:18 +0300 Subject: [PATCH 04/28] Uptate GH_TOKEN. Create Pull Reques from workflow --- .github/workflows/sync-upstream.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 6b295eca95c6..a019feba15e8 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -28,7 +28,7 @@ jobs: with: # optional: set the branch to checkout, ref: upstream - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.ACCESS_TOKEN }} # persist-credentials: false - name: Sync upstream changes @@ -36,7 +36,7 @@ jobs: uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1 with: target_sync_branch: upstream - # target_repo_token: ${{ secrets.GITHUB_TOKEN }} + target_repo_token: ${{ secrets.ACCESS_TOKEN }} upstream_sync_branch: master upstream_sync_repo: polkadot-js/apps @@ -45,8 +45,10 @@ jobs: # Display a sample message based on the sync output var 'has_new_commits' - name: New commits found + id: last_commit if: steps.sync.outputs.has_new_commits == 'true' - run: echo "New commits were found to sync." + run: | + echo "New commits were found to sync." - name: No new commits if: steps.sync.outputs.has_new_commits == 'false' @@ -54,3 +56,11 @@ jobs: - name: Show value of 'has_new_commits' run: echo ${{ steps.sync.outputs.has_new_commits }} + + - name: Create Pull Request + if: steps.sync.outputs.has_new_commits == 'true' + env: + GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} + run: | + LAST_COMMIT_DATE=$(git log -1 --format='%cd' --date=format:'%Y-%m-%d %H:%M:%S' upstream) + gh pr create --title "Upstream sync. Last commit - $LAST_COMMIT_DATE" --body "This Pull Request was created automatically from workflow" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} --repo ${{ github.repository }} From 4de7ab4702416dd808b5bc9ec27a8e2ffaa8b636 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Wed, 21 Aug 2024 11:03:24 +0300 Subject: [PATCH 05/28] Grant all permissions for default GH_TOKEN --- .github/workflows/sync-upstream.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index a019feba15e8..6e98fb23d85b 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -2,6 +2,19 @@ name: 'Upstream Sync' permissions: contents: write + actions: write + attestations: write + checks: write + deployments: write + discussions: write + issues: write + packages: write + pages: write + pull-requests: write + repository-projects: write + security-events: write + statuses: write + on: pull_request: @@ -24,11 +37,11 @@ jobs: steps: - name: Checkout target repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # optional: set the branch to checkout, ref: upstream - token: ${{ secrets.ACCESS_TOKEN }} + token: ${{ github.token }} # persist-credentials: false - name: Sync upstream changes @@ -36,7 +49,7 @@ jobs: uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1 with: target_sync_branch: upstream - target_repo_token: ${{ secrets.ACCESS_TOKEN }} + target_repo_token: ${{ github.token }} upstream_sync_branch: master upstream_sync_repo: polkadot-js/apps @@ -60,7 +73,7 @@ jobs: - name: Create Pull Request if: steps.sync.outputs.has_new_commits == 'true' env: - GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} + GH_TOKEN: ${{ github.token }} run: | LAST_COMMIT_DATE=$(git log -1 --format='%cd' --date=format:'%Y-%m-%d %H:%M:%S' upstream) gh pr create --title "Upstream sync. Last commit - $LAST_COMMIT_DATE" --body "This Pull Request was created automatically from workflow" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} --repo ${{ github.repository }} From 8f6670a97f491246c74f3ba496ae162d2e19cbc7 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Wed, 21 Aug 2024 12:20:33 +0300 Subject: [PATCH 06/28] Reduce permissions for GH_TOKEN. Edit PR structure --- .github/workflows/sync-upstream.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 6e98fb23d85b..2c750d57b8cc 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -3,18 +3,7 @@ name: 'Upstream Sync' permissions: contents: write actions: write - attestations: write - checks: write - deployments: write - discussions: write - issues: write - packages: write - pages: write pull-requests: write - repository-projects: write - security-events: write - statuses: write - on: pull_request: @@ -75,5 +64,4 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - LAST_COMMIT_DATE=$(git log -1 --format='%cd' --date=format:'%Y-%m-%d %H:%M:%S' upstream) - gh pr create --title "Upstream sync. Last commit - $LAST_COMMIT_DATE" --body "This Pull Request was created automatically from workflow" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} --repo ${{ github.repository }} + gh pr create --title "Upstream Sync" --body "[View Workflow Run](${WORKFLOW_URL})" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} --repo ${{ github.repository }} From 609e30141091072304160855eaaa7a9a0ad1df7f Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Wed, 21 Aug 2024 12:29:59 +0300 Subject: [PATCH 07/28] Correct Actions URL --- .github/workflows/sync-upstream.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 2c750d57b8cc..dec90b433c2e 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -64,4 +64,5 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | + WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" gh pr create --title "Upstream Sync" --body "[View Workflow Run](${WORKFLOW_URL})" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} --repo ${{ github.repository }} From b6877af7d6bdb3140e0416389cc2d8687198fed0 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Wed, 21 Aug 2024 12:56:18 +0300 Subject: [PATCH 08/28] Check if PR already exists --- .github/workflows/sync-upstream.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index dec90b433c2e..63dbea0c7bd9 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -56,13 +56,16 @@ jobs: if: steps.sync.outputs.has_new_commits == 'false' run: echo "There were no new commits." - - name: Show value of 'has_new_commits' - run: echo ${{ steps.sync.outputs.has_new_commits }} + - name: Check if PR already exists + id: check_pr_exists + run: | + pr_count=$(gh pr list --repo ${{ github.repository }}) --json 'headRefName' --jq 'map(select(.headRefName == "upstream")) | length' + echo "pr_count=${pr_count}" >> $GITHUB_ENV - name: Create Pull Request - if: steps.sync.outputs.has_new_commits == 'true' + if: steps.sync.outputs.has_new_commits == 'true' && steps.check_pr_exists.outputs.pr_count == '0' env: GH_TOKEN: ${{ github.token }} run: | WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - gh pr create --title "Upstream Sync" --body "[View Workflow Run](${WORKFLOW_URL})" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} --repo ${{ github.repository }} + gh pr create --repo ${{ github.repository }} --title "Upstream Sync" --body "[View Workflow Run](${WORKFLOW_URL})" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} From 7b71fcfcfe6cdb0d5e8689b731b68cfa46624cd1 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Wed, 21 Aug 2024 12:59:24 +0300 Subject: [PATCH 09/28] Check if PR already exists fix 1 --- .github/workflows/sync-upstream.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 63dbea0c7bd9..9e64c576ac44 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -58,6 +58,8 @@ jobs: - name: Check if PR already exists id: check_pr_exists + env: + GH_TOKEN: ${{ github.token }} run: | pr_count=$(gh pr list --repo ${{ github.repository }}) --json 'headRefName' --jq 'map(select(.headRefName == "upstream")) | length' echo "pr_count=${pr_count}" >> $GITHUB_ENV From 8ad432a15ca1e2cacb3fe6fc711396d5fa3f3e09 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Wed, 21 Aug 2024 13:06:39 +0300 Subject: [PATCH 10/28] Check if PR already exists fix 2 --- .github/workflows/sync-upstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 9e64c576ac44..934f0564f825 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -61,7 +61,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - pr_count=$(gh pr list --repo ${{ github.repository }}) --json 'headRefName' --jq 'map(select(.headRefName == "upstream")) | length' + pr_count=$(gh pr list --repo ${{ github.repository }} --json 'headRefName' --jq 'map(select(.headRefName == "upstream")) | length') echo "pr_count=${pr_count}" >> $GITHUB_ENV - name: Create Pull Request From 64473fd817ba72f3cad72c865e4a874ea41a5055 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Thu, 22 Aug 2024 16:02:53 +0300 Subject: [PATCH 11/28] Change sync branch from action to bash commands --- .github/workflows/sync-upstream.yml | 54 ++++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 934f0564f825..58de0962216a 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -12,9 +12,9 @@ on: - cron: '0 7 * * 1' # scheduled at 07:00 every Monday - workflow_dispatch: # click the button on Github repo! + workflow_dispatch: inputs: - sync_test_mode: # Adds a boolean option that appears during manual workflow run for easy test mode config + sync_test_mode: description: 'Fork Sync Test Mode' type: boolean default: false @@ -28,35 +28,33 @@ jobs: - name: Checkout target repo uses: actions/checkout@v4 with: - # optional: set the branch to checkout, ref: upstream - token: ${{ github.token }} - # persist-credentials: false - name: Sync upstream changes id: sync - uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1 - with: - target_sync_branch: upstream - target_repo_token: ${{ github.token }} - upstream_sync_branch: master - upstream_sync_repo: polkadot-js/apps - - # Set test_mode true during manual dispatch to run tests instead of the true action!! - test_mode: ${{ inputs.sync_test_mode }} - - # Display a sample message based on the sync output var 'has_new_commits' - - name: New commits found - id: last_commit - if: steps.sync.outputs.has_new_commits == 'true' - run: | - echo "New commits were found to sync." + run: | + git remote add --fetch upstream git@github.com:polkadot-js/apps.git + git branch -u upstream/master upstream + git pull upstream --ff-only + + - name: Check if there are new commits + id: check_commits + run: | + if git status --porcelain | grep -q '^\s*modified:.*'; then + echo "New commits found" + echo "new_commits=true" >> $GITHUB_ENV + else + echo "This branch is up to date" + echo "new_commits=false" >> $GITHUB_ENV + fi - - name: No new commits - if: steps.sync.outputs.has_new_commits == 'false' - run: echo "There were no new commits." + - name: Push changes to origin + if: steps.check_commits.outputs.new_commit == 'true' + run: | + git push origin upstream - name: Check if PR already exists + if: steps.check_commits.outputs.new_commit == 'true' id: check_pr_exists env: GH_TOKEN: ${{ github.token }} @@ -64,8 +62,14 @@ jobs: pr_count=$(gh pr list --repo ${{ github.repository }} --json 'headRefName' --jq 'map(select(.headRefName == "upstream")) | length') echo "pr_count=${pr_count}" >> $GITHUB_ENV + if [ "$pr_count" -gt 0 ]; then + echo "Pull Request already exists." + else + echo "Pull Request not found. It will be created" + fi + - name: Create Pull Request - if: steps.sync.outputs.has_new_commits == 'true' && steps.check_pr_exists.outputs.pr_count == '0' + if: steps.check_commits.outputs.new_commit == 'true' && steps.check_pr_exists.outputs.pr_count == '0' env: GH_TOKEN: ${{ github.token }} run: | From c5f2333720b5535313e6a4e4bf03c3edabae5b6a Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Thu, 22 Aug 2024 16:45:49 +0300 Subject: [PATCH 12/28] Add GH_account --- .github/workflows/sync-upstream.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 58de0962216a..c669717108ad 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -30,10 +30,15 @@ jobs: with: ref: upstream + - name: Configure Git + run: | + git config user.name 'GitHub Actions' + git config user.email 'actions@github.com' + - name: Sync upstream changes id: sync run: | - git remote add --fetch upstream git@github.com:polkadot-js/apps.git + git remote add --fetch upstream https://github.com/polkadot-js/apps.git git branch -u upstream/master upstream git pull upstream --ff-only From de3e5c406f3bf60107addef289a1279b4495293b Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Thu, 22 Aug 2024 18:11:45 +0300 Subject: [PATCH 13/28] Check if there are new commits to sync --- .github/workflows/sync-upstream.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index c669717108ad..8c625b7efa16 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -38,14 +38,15 @@ jobs: - name: Sync upstream changes id: sync run: | + git branch git remote add --fetch upstream https://github.com/polkadot-js/apps.git git branch -u upstream/master upstream git pull upstream --ff-only - - name: Check if there are new commits + - name: Check if there are new commits to sync id: check_commits run: | - if git status --porcelain | grep -q '^\s*modified:.*'; then + if if [ $(git rev-list HEAD...upstream/master --count) -ne 0 ]; then echo "New commits found" echo "new_commits=true" >> $GITHUB_ENV else From 1875ff9e379f7a028ace405857b226d0a63e3faf Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Thu, 22 Aug 2024 18:15:05 +0300 Subject: [PATCH 14/28] Check if there are new commits to sync fix 1 --- .github/workflows/sync-upstream.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 8c625b7efa16..f2acc97f56ba 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -38,15 +38,13 @@ jobs: - name: Sync upstream changes id: sync run: | - git branch git remote add --fetch upstream https://github.com/polkadot-js/apps.git git branch -u upstream/master upstream - git pull upstream --ff-only - name: Check if there are new commits to sync id: check_commits run: | - if if [ $(git rev-list HEAD...upstream/master --count) -ne 0 ]; then + if [ $(git rev-list HEAD...upstream/master --count) -ne 0 ]; then echo "New commits found" echo "new_commits=true" >> $GITHUB_ENV else @@ -57,7 +55,8 @@ jobs: - name: Push changes to origin if: steps.check_commits.outputs.new_commit == 'true' run: | - git push origin upstream + git pull upstream --ff-only + git push origin upstream - name: Check if PR already exists if: steps.check_commits.outputs.new_commit == 'true' From 4015119bf12097979dcda6bf540240a8ecca859a Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Thu, 22 Aug 2024 18:27:59 +0300 Subject: [PATCH 15/28] Check if there are new commits to sync fix 2 --- .github/workflows/sync-upstream.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index f2acc97f56ba..36a8cbd47769 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -46,10 +46,10 @@ jobs: run: | if [ $(git rev-list HEAD...upstream/master --count) -ne 0 ]; then echo "New commits found" - echo "new_commits=true" >> $GITHUB_ENV + echo "::set-output name=new_commits::true" else echo "This branch is up to date" - echo "new_commits=false" >> $GITHUB_ENV + echo "::set-output name=new_commits::false" fi - name: Push changes to origin @@ -58,14 +58,14 @@ jobs: git pull upstream --ff-only git push origin upstream - - name: Check if PR already exists + - name: Push changes to origin if: steps.check_commits.outputs.new_commit == 'true' id: check_pr_exists env: GH_TOKEN: ${{ github.token }} run: | pr_count=$(gh pr list --repo ${{ github.repository }} --json 'headRefName' --jq 'map(select(.headRefName == "upstream")) | length') - echo "pr_count=${pr_count}" >> $GITHUB_ENV + echo "::set-output name=pr_count::${pr_count}" if [ "$pr_count" -gt 0 ]; then echo "Pull Request already exists." From ed2b9582faa5992fb065587f85337e4f7d999b7e Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Thu, 22 Aug 2024 18:33:36 +0300 Subject: [PATCH 16/28] Check if there are new commits to sync fix 3 --- .github/workflows/sync-upstream.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 36a8cbd47769..ebe69fd8682e 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -46,26 +46,26 @@ jobs: run: | if [ $(git rev-list HEAD...upstream/master --count) -ne 0 ]; then echo "New commits found" - echo "::set-output name=new_commits::true" + echo "new_commits=true" >> $GITHUB_ENV else echo "This branch is up to date" - echo "::set-output name=new_commits::false" + echo "new_commits=false" >> $GITHUB_ENV fi - name: Push changes to origin - if: steps.check_commits.outputs.new_commit == 'true' + if: env.new_commits == 'true' run: | git pull upstream --ff-only git push origin upstream - name: Push changes to origin - if: steps.check_commits.outputs.new_commit == 'true' + if: env.new_commits == 'true' id: check_pr_exists env: GH_TOKEN: ${{ github.token }} run: | pr_count=$(gh pr list --repo ${{ github.repository }} --json 'headRefName' --jq 'map(select(.headRefName == "upstream")) | length') - echo "::set-output name=pr_count::${pr_count}" + echo "pr_count=${pr_count}" >> $GITHUB_ENV if [ "$pr_count" -gt 0 ]; then echo "Pull Request already exists." @@ -74,7 +74,7 @@ jobs: fi - name: Create Pull Request - if: steps.check_commits.outputs.new_commit == 'true' && steps.check_pr_exists.outputs.pr_count == '0' + if: env.new_commits == 'true' && env.pr_count == '0' env: GH_TOKEN: ${{ github.token }} run: | From 2ab70c61b69497d31f861ec09faefca493b7e770 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Thu, 22 Aug 2024 18:44:05 +0300 Subject: [PATCH 17/28] Check if there are new commits to sync fix 4 --- .github/workflows/sync-upstream.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index ebe69fd8682e..ddc6d7373d35 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -37,8 +37,10 @@ jobs: - name: Sync upstream changes id: sync + env: + GH_TOKEN: ${{ github.token }} run: | - git remote add --fetch upstream https://github.com/polkadot-js/apps.git + git remote add --fetch upstream https://${GH_TOKEN}@github.com/polkadot-js/apps.git git branch -u upstream/master upstream - name: Check if there are new commits to sync @@ -54,9 +56,11 @@ jobs: - name: Push changes to origin if: env.new_commits == 'true' + env: + GH_TOKEN: ${{ github.token }} run: | git pull upstream --ff-only - git push origin upstream + git push https://${GH_TOKEN}@github.com/${{ github.repository }} upstream - name: Push changes to origin if: env.new_commits == 'true' From 2c1115d457915b038b140be92e88c75afeb161b6 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 10:23:09 +0300 Subject: [PATCH 18/28] Check if there are new commits to sync fix 5 --- .github/workflows/sync-upstream.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index ddc6d7373d35..faeb5177a257 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -4,6 +4,16 @@ permissions: contents: write actions: write pull-requests: write + attestations: write + checks: write + deployments: write + discussions: write + issues: write + packages: write + pages: write + repository-projects: write + security-events: write + statuses: write on: pull_request: From 7b7cd4762977aa4f3927a6acd2f045e260794540 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 10:49:54 +0300 Subject: [PATCH 19/28] Check if there are new commits to sync fix 6 --- .github/workflows/sync-upstream.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index faeb5177a257..5fed36aa2980 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -39,6 +39,7 @@ jobs: uses: actions/checkout@v4 with: ref: upstream + token: ${{ github.token }} - name: Configure Git run: | @@ -47,10 +48,8 @@ jobs: - name: Sync upstream changes id: sync - env: - GH_TOKEN: ${{ github.token }} run: | - git remote add --fetch upstream https://${GH_TOKEN}@github.com/polkadot-js/apps.git + git remote add --fetch upstream https://github.com/polkadot-js/apps.git git branch -u upstream/master upstream - name: Check if there are new commits to sync @@ -70,6 +69,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | git pull upstream --ff-only + echo ${{ github.repository }} git push https://${GH_TOKEN}@github.com/${{ github.repository }} upstream - name: Push changes to origin From 3fc1d6b534b3512f7fe4ca6db394118388b672cb Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 10:56:34 +0300 Subject: [PATCH 20/28] Check if there are new commits to sync fix 7 --- .github/workflows/sync-upstream.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 5fed36aa2980..4bab53710383 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@v4 with: ref: upstream - token: ${{ github.token }} + token: ${{ secrets.ACCESS_TOKEN }} - name: Configure Git run: | @@ -66,7 +66,7 @@ jobs: - name: Push changes to origin if: env.new_commits == 'true' env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: | git pull upstream --ff-only echo ${{ github.repository }} From f36d270ea41683e819a3f0a3eaa499d1caaf05db Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 11:08:14 +0300 Subject: [PATCH 21/28] Check if there are new commits to sync fix 8 --- .github/workflows/sync-upstream.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 4bab53710383..35ec485aea75 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -39,12 +39,7 @@ jobs: uses: actions/checkout@v4 with: ref: upstream - token: ${{ secrets.ACCESS_TOKEN }} - - - name: Configure Git - run: | - git config user.name 'GitHub Actions' - git config user.email 'actions@github.com' + token: ${{ github.token }} - name: Sync upstream changes id: sync @@ -66,11 +61,10 @@ jobs: - name: Push changes to origin if: env.new_commits == 'true' env: - GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} + GH_TOKEN: ${{ github.token }} run: | - git pull upstream --ff-only - echo ${{ github.repository }} - git push https://${GH_TOKEN}@github.com/${{ github.repository }} upstream + gh repo set-default ${{ github.repository }} + gh repo sync origin/main --source upstream/main - name: Push changes to origin if: env.new_commits == 'true' From d87d6dcca7e5a82b975f427f8159c0cd62dc3bce Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 11:27:00 +0300 Subject: [PATCH 22/28] Check if there are new commits to sync fix 9 --- .github/workflows/sync-upstream.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 35ec485aea75..e9518d57c151 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -43,6 +43,8 @@ jobs: - name: Sync upstream changes id: sync + env: + GH_TOKEN: ${{ github.token }} run: | git remote add --fetch upstream https://github.com/polkadot-js/apps.git git branch -u upstream/master upstream @@ -63,8 +65,8 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - gh repo set-default ${{ github.repository }} - gh repo sync origin/main --source upstream/main + git pull upstream --ff-only + git push origin upstream - name: Push changes to origin if: env.new_commits == 'true' From b4f353113ebd7a87df5b2a219af65892f681b1e4 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 11:28:35 +0300 Subject: [PATCH 23/28] Check if there are new commits to sync fix 10 --- .github/workflows/sync-upstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index e9518d57c151..05079f633f63 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -63,7 +63,7 @@ jobs: - name: Push changes to origin if: env.new_commits == 'true' env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: | git pull upstream --ff-only git push origin upstream From 2182e0cb3b43d6ed54a874a1a0c5de251ebbd0f5 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 11:35:40 +0300 Subject: [PATCH 24/28] Check if there are new commits to sync fix 11 --- .github/workflows/sync-upstream.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 05079f633f63..3dbf5a2be310 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -39,12 +39,10 @@ jobs: uses: actions/checkout@v4 with: ref: upstream - token: ${{ github.token }} + token: ${{ secrets.ACCESS_TOKEN }} - name: Sync upstream changes id: sync - env: - GH_TOKEN: ${{ github.token }} run: | git remote add --fetch upstream https://github.com/polkadot-js/apps.git git branch -u upstream/master upstream @@ -59,15 +57,14 @@ jobs: echo "This branch is up to date" echo "new_commits=false" >> $GITHUB_ENV fi - - name: Push changes to origin if: env.new_commits == 'true' env: GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: | git pull upstream --ff-only - git push origin upstream - + echo ${{ github.repository }} + git push https://${GH_TOKEN}@github.com/${{ github.repository }} upstream - name: Push changes to origin if: env.new_commits == 'true' id: check_pr_exists @@ -76,17 +73,15 @@ jobs: run: | pr_count=$(gh pr list --repo ${{ github.repository }} --json 'headRefName' --jq 'map(select(.headRefName == "upstream")) | length') echo "pr_count=${pr_count}" >> $GITHUB_ENV - if [ "$pr_count" -gt 0 ]; then echo "Pull Request already exists." else echo "Pull Request not found. It will be created" fi - - name: Create Pull Request if: env.new_commits == 'true' && env.pr_count == '0' env: GH_TOKEN: ${{ github.token }} run: | WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - gh pr create --repo ${{ github.repository }} --title "Upstream Sync" --body "[View Workflow Run](${WORKFLOW_URL})" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} + gh pr create --repo ${{ github.repository }} --title "Upstream Sync" --body "[View Workflow Run](${WORKFLOW_URL})" --head upstream --base test-auto-pr --reviewer ${{ secrets.REVIEWER_1 }} \ No newline at end of file From 67a3345f03c05df6b9e891255d479aafe665c52c Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 11:43:00 +0300 Subject: [PATCH 25/28] Check if there are new commits to sync fix 11 --- .github/workflows/sync-upstream.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 3dbf5a2be310..b39f81c7457d 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@v4 with: ref: upstream - token: ${{ secrets.ACCESS_TOKEN }} + token: ${{ github.token }} - name: Sync upstream changes id: sync @@ -57,14 +57,16 @@ jobs: echo "This branch is up to date" echo "new_commits=false" >> $GITHUB_ENV fi + - name: Push changes to origin if: env.new_commits == 'true' env: - GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} + GH_TOKEN: ${{ github.token }} run: | git pull upstream --ff-only echo ${{ github.repository }} - git push https://${GH_TOKEN}@github.com/${{ github.repository }} upstream + git push https://${GITHUB_ACTOR}:${GH_TOKEN}@github.com/${{ github.repository }} upstream + - name: Push changes to origin if: env.new_commits == 'true' id: check_pr_exists @@ -78,6 +80,7 @@ jobs: else echo "Pull Request not found. It will be created" fi + - name: Create Pull Request if: env.new_commits == 'true' && env.pr_count == '0' env: From ab5d725f74511006aae31cfacd1ff9b3b3fb3c65 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 11:51:28 +0300 Subject: [PATCH 26/28] Check if there are new commits to sync fix 12 --- .github/workflows/sync-upstream.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index b39f81c7457d..8531fd21aa34 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -61,11 +61,11 @@ jobs: - name: Push changes to origin if: env.new_commits == 'true' env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: | git pull upstream --ff-only echo ${{ github.repository }} - git push https://${GITHUB_ACTOR}:${GH_TOKEN}@github.com/${{ github.repository }} upstream + git push https://${GH_TOKEN}@github.com/${{ github.repository }} upstream - name: Push changes to origin if: env.new_commits == 'true' From 88ebd7389abb5f5dafd9e6156102e2d78c6060bd Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 11:52:53 +0300 Subject: [PATCH 27/28] Check if there are new commits to sync fix 13 --- .github/workflows/sync-upstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 8531fd21aa34..8f1cfac84c66 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@v4 with: ref: upstream - token: ${{ github.token }} + token: ${{ secrets.ACCESS_TOKEN }} - name: Sync upstream changes id: sync From b7fae7daa73b0e7ac7ae0a954ab936aa531f5926 Mon Sep 17 00:00:00 2001 From: semeniak97mf Date: Fri, 23 Aug 2024 16:20:16 +0300 Subject: [PATCH 28/28] Revert to actions in upstream --- .github/workflows/sync-upstream.yml | 54 +++++++---------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 8f1cfac84c66..94599ab24158 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -4,16 +4,6 @@ permissions: contents: write actions: write pull-requests: write - attestations: write - checks: write - deployments: write - discussions: write - issues: write - packages: write - pages: write - repository-projects: write - security-events: write - statuses: write on: pull_request: @@ -23,11 +13,6 @@ on: # scheduled at 07:00 every Monday workflow_dispatch: - inputs: - sync_test_mode: - description: 'Fork Sync Test Mode' - type: boolean - default: false jobs: sync_latest_from_upstream: @@ -39,36 +24,23 @@ jobs: uses: actions/checkout@v4 with: ref: upstream - token: ${{ secrets.ACCESS_TOKEN }} + token: ${{ github.token }} - name: Sync upstream changes id: sync - run: | - git remote add --fetch upstream https://github.com/polkadot-js/apps.git - git branch -u upstream/master upstream - - - name: Check if there are new commits to sync - id: check_commits - run: | - if [ $(git rev-list HEAD...upstream/master --count) -ne 0 ]; then - echo "New commits found" - echo "new_commits=true" >> $GITHUB_ENV - else - echo "This branch is up to date" - echo "new_commits=false" >> $GITHUB_ENV - fi + uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1 + with: + target_sync_branch: upstream + target_repo_token: ${{ github.token }} + upstream_sync_branch: master + upstream_sync_repo: polkadot-js/apps - - name: Push changes to origin - if: env.new_commits == 'true' - env: - GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} - run: | - git pull upstream --ff-only - echo ${{ github.repository }} - git push https://${GH_TOKEN}@github.com/${{ github.repository }} upstream + - name: Output sync status + run: | + echo "Commits to sync: ${{ steps.sync.outputs.has_new_commits }}" - - name: Push changes to origin - if: env.new_commits == 'true' + - name: Check if PR already exists + if: steps.sync.outputs.has_new_commits == 'true' id: check_pr_exists env: GH_TOKEN: ${{ github.token }} @@ -82,7 +54,7 @@ jobs: fi - name: Create Pull Request - if: env.new_commits == 'true' && env.pr_count == '0' + if: steps.sync.outputs.has_new_commits == 'true' && env.pr_count == '0' env: GH_TOKEN: ${{ github.token }} run: |