From 72d19cc3e60817864ddf871410e80ff522972b75 Mon Sep 17 00:00:00 2001 From: Angus Bayley Date: Thu, 2 Jan 2025 12:28:58 +0000 Subject: [PATCH 1/6] TEMP - make generate-screenshots simplest possible test of a dummy commit using swinton --- .github/workflows/generate-screenshots.yml | 144 ++------------------- 1 file changed, 9 insertions(+), 135 deletions(-) diff --git a/.github/workflows/generate-screenshots.yml b/.github/workflows/generate-screenshots.yml index 7752446dacba..b4b92d4c2876 100644 --- a/.github/workflows/generate-screenshots.yml +++ b/.github/workflows/generate-screenshots.yml @@ -34,140 +34,14 @@ jobs: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 runs-on: [ledger-live-4xlarge] steps: - - name: generate token - id: generate-token - uses: tibdex/github-app-token@v1 - with: - app_id: ${{ secrets.GH_BOT_APP_ID }} - private_key: ${{ secrets.GH_BOT_PRIVATE_KEY }} - - - uses: actions/checkout@v4 - if: ${{ inputs.ref != null }} - with: - ref: ${{ inputs.ref }} - fetch-depth: 0 - token: ${{ steps.generate-token.outputs.token }} - - uses: actions/checkout@v4 - if: ${{ !inputs.ref }} - with: - fetch-depth: 0 - token: ${{ steps.generate-token.outputs.token }} - - name: Checkout PR - if: ${{ inputs.number != null }} - run: gh pr checkout ${{ inputs.number }} + - name: Create dummy file + run: echo "This is a dummy file" > dummyfile.txt + - name: Commit file + uses: swinton/commit@v2.x env: - GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} - - - name: Setup git user - uses: LedgerHQ/ledger-live/tools/actions/composites/setup-git-user@develop - - name: Setup the toolchain - id: caches - uses: LedgerHQ/ledger-live/tools/actions/composites/setup-caches@develop - with: - accountId: ${{ secrets.AWS_ACCOUNT_ID_PROD }} - roleName: ${{ secrets.AWS_CACHE_ROLE_NAME }} - region: ${{ secrets.AWS_CACHE_REGION }} - turbo-server-token: ${{ secrets.TURBOREPO_SERVER_TOKEN }} - - uses: LedgerHQ/ledger-live/tools/actions/composites/setup-test-desktop@develop - id: setup-test-desktop - with: - skip_ruby: true - install_playwright: true - turborepo-server-port: ${{ steps.caches.outputs.port }} - - uses: LedgerHQ/ledger-live/tools/actions/composites/update-snapshots-desktop@develop - id: update-snapshots - with: - os: ubuntu-22.04 - - report-start: - name: Report start - runs-on: ubuntu-22.04 - if: inputs.commentId != '' - steps: - - name: generate token - id: generate-token - uses: tibdex/github-app-token@v1 - with: - app_id: ${{ secrets.GH_BOT_APP_ID }} - private_key: ${{ secrets.GH_BOT_PRIVATE_KEY }} - - name: report start - uses: actions/github-script@v7 - with: - github-token: ${{ steps.generate-token.outputs.token }} - result-encoding: string - retries: 3 - script: | - const {repo: {owner, repo}, run_id} = context - const issue_number = ${{ inputs.number }} - const body = `\ - @${{ inputs.login }} - - [Generating screenshots: workflow started](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - ` - await github.rest.issues.updateComment({ - owner, - repo, - comment_id: "${{ inputs.commentId }}", - body, - }); - - report-end: - needs: ["generate-screenshots-linux", "report-start"] - if: ${{ !cancelled() }} - name: Report end - runs-on: ubuntu-22.04 - steps: - - name: generate token - id: generate-token - uses: tibdex/github-app-token@v1 - with: - app_id: ${{ secrets.GH_BOT_APP_ID }} - private_key: ${{ secrets.GH_BOT_PRIVATE_KEY }} - - name: report jobs status - uses: actions/github-script@v7 - with: - github-token: ${{ steps.generate-token.outputs.token }} - result-encoding: string - retries: 3 - script: | - const fs = require("fs"); - const {repo: {owner, repo}} = context; - const {data: {jobs}} = await github.rest.actions.listJobsForWorkflowRun({ - owner, - repo, - run_id: ${{ github.run_id }}, - }); - - const jobsStatusString = jobs - .filter(job => job.name.startsWith("generate-screenshots")) - .map(job => `${job.conclusion === "success" ? "✅" : "❌"} - [${job.name}](${job.html_url})`) - .join("\n") - - const body = `\ - @${{ inputs.login }} - - [Generating screenshots: workflow ended](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - **Jobs status:** - ${jobsStatusString} - ` - - const output = { - summary: body, - }; - - fs.writeFileSync("summary.json", JSON.stringify(output), "utf-8"); - - if(${{ inputs.commentId != '' }}) { - await github.rest.issues.updateComment({ - owner, - repo, - comment_id: "${{ inputs.commentId }}", - body - }); - } - - uses: actions/upload-artifact@v4 - name: upload summary + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - name: summary.json - path: ${{ github.workspace }}/summary.json + files: | + ./dummyfile.txt + commit-message: Committing ./myfile + ref: refs/heads/support/signed-screenshot-gh-commits-swinton-test-2 From 75bb99ea0b11f8ee5e93e68d32de377ef38df2a8 Mon Sep 17 00:00:00 2001 From: Angus Bayley Date: Thu, 2 Jan 2025 12:52:12 +0000 Subject: [PATCH 2/6] explicitly give write permissions --- .github/workflows/generate-screenshots.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/generate-screenshots.yml b/.github/workflows/generate-screenshots.yml index b4b92d4c2876..3c247fa94b50 100644 --- a/.github/workflows/generate-screenshots.yml +++ b/.github/workflows/generate-screenshots.yml @@ -28,6 +28,10 @@ permissions: jobs: generate-screenshots-linux: + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # added or changed files to the repository. + contents: write env: NODE_OPTIONS: "--max-old-space-size=7168" FORCE_COLOR: 3 From 6e8711fa64070065a57c260a565b54af60cdc348 Mon Sep 17 00:00:00 2001 From: Angus Bayley Date: Thu, 2 Jan 2025 12:58:42 +0000 Subject: [PATCH 3/6] add debug lines --- .github/workflows/generate-screenshots.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate-screenshots.yml b/.github/workflows/generate-screenshots.yml index 3c247fa94b50..d70cc615d0bf 100644 --- a/.github/workflows/generate-screenshots.yml +++ b/.github/workflows/generate-screenshots.yml @@ -40,12 +40,16 @@ jobs: steps: - name: Create dummy file run: echo "This is a dummy file" > dummyfile.txt + - name: List dummy file + run: ls -l dummyfile.txt + - name: Display dummy file contents + run: cat dummyfile.txt - name: Commit file uses: swinton/commit@v2.x env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: files: | - ./dummyfile.txt - commit-message: Committing ./myfile + dummyfile.txt + commit-message: Committing dummyfile.txt ref: refs/heads/support/signed-screenshot-gh-commits-swinton-test-2 From 8a413f44aa2bf3aa660a50eba95f3219888125aa Mon Sep 17 00:00:00 2001 From: Angus Bayley Date: Thu, 2 Jan 2025 16:30:40 +0000 Subject: [PATCH 4/6] try 2nd approach too --- .github/workflows/generate-screenshots.yml | 31 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate-screenshots.yml b/.github/workflows/generate-screenshots.yml index d70cc615d0bf..0e37e6f945a8 100644 --- a/.github/workflows/generate-screenshots.yml +++ b/.github/workflows/generate-screenshots.yml @@ -38,14 +38,24 @@ jobs: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 runs-on: [ledger-live-4xlarge] steps: + - name: generate token + id: generate-token + uses: tibdex/github-app-token@v1 + with: + app_id: ${{ secrets.GH_BOT_APP_ID }} + private_key: ${{ secrets.GH_BOT_PRIVATE_KEY }} + - uses: actions/checkout@v4 + if: ${{ inputs.ref != null }} + with: + ref: ${{ inputs.ref }} + fetch-depth: 0 + token: ${{ steps.generate-token.outputs.token }} - name: Create dummy file run: echo "This is a dummy file" > dummyfile.txt - - name: List dummy file - run: ls -l dummyfile.txt - name: Display dummy file contents run: cat dummyfile.txt - name: Commit file - uses: swinton/commit@v2.x + uses: swinton/commit@v2.0.0 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -53,3 +63,18 @@ jobs: dummyfile.txt commit-message: Committing dummyfile.txt ref: refs/heads/support/signed-screenshot-gh-commits-swinton-test-2 + - name: Force pull latest changes + run: git fetch origin ${{ inputs.ref }} && git reset --hard FETCH_HEAD + - name: Create 2nd dummy file + run: echo "This is a SECOND dummy file" > dummyfile2.txt + - name: Display dummy file 2 contents + run: cat dummyfile2.txt + - name: Commit updated screenshots to PR + id: commit-screenshots + uses: stefanzweifel/git-auto-commit-action@v5 + env: + token: ${{ secrets.GITHUB_TOKEN }} + with: + file_pattern: "dummyfile2.txt" + commit_message: "commit dummyfile 2" + From f3cd4fb8e11c9ac7e7e63ec6ad5022d08f652f27 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 17:52:03 +0000 Subject: [PATCH 5/6] Committing dummyfile.txt --- dummyfile.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 dummyfile.txt diff --git a/dummyfile.txt b/dummyfile.txt new file mode 100644 index 000000000000..6ca8147f8b21 --- /dev/null +++ b/dummyfile.txt @@ -0,0 +1 @@ +This is a dummy file From 9280f22e446ef6ed7fb1290fcba586c33f37e01d Mon Sep 17 00:00:00 2001 From: angusbayley Date: Thu, 2 Jan 2025 17:52:23 +0000 Subject: [PATCH 6/6] commit dummyfile 2 --- dummyfile2.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 dummyfile2.txt diff --git a/dummyfile2.txt b/dummyfile2.txt new file mode 100644 index 000000000000..92bbbfcd9fe8 --- /dev/null +++ b/dummyfile2.txt @@ -0,0 +1 @@ +This is a SECOND dummy file