Skip to content

@Desktop • Generate Screenshots triggered by gre on PR 5823 #887

@Desktop • Generate Screenshots triggered by gre on PR 5823

@Desktop • Generate Screenshots triggered by gre on PR 5823 #887

name: "@Desktop • Generate Screenshots"
run-name: "@Desktop • Generate Screenshots triggered by ${{ inputs.login }} ${{ inputs.ref && format('on branch {0}', inputs.ref) || format('on PR {0}', inputs.number) }}"
on:
workflow_dispatch:
inputs:
ref:
description: The branch to generate screenshots for.
required: false
number:
description: The pull request number.
required: false
login:
description: The GitHub username that triggered the workflow
required: false
commentId:
description: comment id to update
required: false
concurrency:
# See: https://github.com/orgs/community/discussions/35341
group: ${{ github.workflow }}-${{ github.event.inputs.ref || github.event.inputs.number }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
jobs:
generate-screenshots-linux:
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
runs-on: [ledger-live-4xlarge-linux]
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: Install gh
run: |
type -p curl >/dev/null || sudo apt install curl -y
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Checkout PR
if: ${{ inputs.number != null && inputs.ref == null }}
run: gh pr checkout ${{ inputs.number }}
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Setup git user
uses: ./tools/actions/composites/setup-git-user
- name: Setup the toolchain
id: toolchain
uses: ./tools/actions/composites/setup-toolchain
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: ./tools/actions/composites/setup-test-desktop
id: setup-test-desktop
with:
skip_ruby: true
install_playwright: true
turborepo-server-port: ${{ steps.toolchain.outputs.port }}
- uses: ./tools/actions/composites/update-snapshots-desktop
id: update-snapshots
with:
os: ubuntu-latest
generate-screenshots-windows:
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
runs-on: [ledger-live-4xlarge-windows-2022]
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 && inputs.ref == null }}
run: gh pr checkout ${{ inputs.number }}
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Setup the toolchain
uses: ./tools/actions/composites/setup-toolchain
id: toolchain
with:
upgrade_npm: true
skip_turbo_cache: "false"
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: ./tools/actions/composites/setup-test-desktop
id: setup-test-desktop
with:
skip_ruby: true
install_playwright: true
turborepo-server-port: ${{ steps.toolchain.outputs.port }}
- name: Setup git user
uses: ./tools/actions/composites/setup-git-user
- uses: ./tools/actions/composites/update-snapshots-desktop
id: update-snapshots
with:
os: windows-latest
generate-screenshots-mac:
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
runs-on: [m1, ARM64]
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 && inputs.ref == null }}
run: gh pr checkout ${{ inputs.number }}
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Setup the toolchain
uses: ./tools/actions/composites/setup-toolchain
id: toolchain
with:
# skip_pnpm_cache: "true"
skip_turbo_cache: "false"
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: ./tools/actions/composites/setup-test-desktop
id: setup-test-desktop
with:
skip_ruby: true
install_playwright: true
turborepo-server-port: ${{ steps.toolchain.outputs.port }}
- name: Setup git user
uses: ./tools/actions/composites/setup-git-user
- uses: ./tools/actions/composites/update-snapshots-desktop
id: update-snapshots
with:
os: macos-latest
report-start:
name: Report start
runs-on: ubuntu-latest
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@v6
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",
"generate-screenshots-windows",
"generate-screenshots-mac",
"report-start",
]
if: always()
name: Report end
runs-on: "ubuntu-latest"
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@v6
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@v3
name: upload summary
with:
name: summary.json
path: ${{ github.workspace }}/summary.json