Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental - simplest test of a swinton (hopefully signed) commit #8786

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 29 additions & 122 deletions .github/workflows/generate-screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/[email protected]
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"

1 change: 1 addition & 0 deletions dummyfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a dummy file
1 change: 1 addition & 0 deletions dummyfile2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a SECOND dummy file
Loading