diff --git a/.github/workflows/generate-screenshots.yml b/.github/workflows/generate-screenshots.yml index 7752446dacba..0e37e6f945a8 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 @@ -40,134 +44,37 @@ jobs: 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: Display dummy file contents + run: cat dummyfile.txt + - name: Commit file + uses: swinton/commit@v2.0.0 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 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 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 + files: | + 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: - name: summary.json - path: ${{ github.workspace }}/summary.json + file_pattern: "dummyfile2.txt" + commit_message: "commit dummyfile 2" + 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 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