From 2d56a6740c73af3b78f875fd97259c1465f8fe8a Mon Sep 17 00:00:00 2001 From: Jordan Gensler Date: Fri, 23 Sep 2022 12:59:37 -0700 Subject: [PATCH 1/4] Workflow run wallet extension --- .github/workflows/wallet-ext-comment.yml | 38 ++++++++++++++++++++++++ .github/workflows/wallet-ext-prs.yml | 14 +++------ wallet/README.md | 1 + 3 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/wallet-ext-comment.yml diff --git a/.github/workflows/wallet-ext-comment.yml b/.github/workflows/wallet-ext-comment.yml new file mode 100644 index 0000000000000..68d4f00ac4cf2 --- /dev/null +++ b/.github/workflows/wallet-ext-comment.yml @@ -0,0 +1,38 @@ +name: Wallet Extension PR Comment + +# NOTE: This workflow run indirection is used to securely comment on PRs when +# wallet builds are completed. +on: + workflow_run: + workflows: ["Wallet Extension PR Checks"] + types: + - completed + +jobs: + upload: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + steps: + - name: 'Download artifact' + uses: actions/github-script@v3.1.0 + with: + script: | + var artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{github.event.workflow_run.id }}, + }); + + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "wallet-extension" + })[0]; + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v1 + with: + comment_includes: "💳 Wallet Extension" + message: | + 💳 Wallet Extension has been built, you can download the packaged extension here: https://github.com/MystenLabs/sui/actions/runs/${{ github.run_id }}#artifacts + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/wallet-ext-prs.yml b/.github/workflows/wallet-ext-prs.yml index dae5d2b2bde1a..879e6472f3818 100644 --- a/.github/workflows/wallet-ext-prs.yml +++ b/.github/workflows/wallet-ext-prs.yml @@ -1,8 +1,8 @@ -name: Wallet Extension PR checks +name: Wallet Extension PR Checks on: pull_request jobs: diff: - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest outputs: isWalletExt: ${{ steps.diff.outputs.isWalletExt }} steps: @@ -10,11 +10,12 @@ jobs: - name: Detect Changes uses: "./.github/actions/pnpm-diffs" id: diff + run_checks: name: Lint, Test & Build needs: diff if: needs.diff.outputs.isWalletExt == 'true' - runs-on: [ubuntu-latest] + runs-on: ubuntu-latest env: working-directory: ./wallet steps: @@ -49,10 +50,3 @@ jobs: path: wallet/web-ext-artifacts/* if-no-files-found: error retention-days: 7 - - name: Comment PR - uses: thollander/actions-comment-pull-request@v1 - with: - comment_includes: "💳 Wallet Extension" - message: | - 💳 Wallet Extension has been built, you can download the packaged extension here: https://github.com/MystenLabs/sui/actions/runs/${{ github.run_id }}#artifacts - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/wallet/README.md b/wallet/README.md index 2a435945c4f9b..ae5123aca2ba0 100644 --- a/wallet/README.md +++ b/wallet/README.md @@ -1,5 +1,6 @@ # Sui Wallet + A Chrome (v88+) extension wallet for [Sui](https://sui.io). # Set Up From c670d8f547237591fe243b0832fc491b02714313 Mon Sep 17 00:00:00 2001 From: Jordan Gensler Date: Fri, 23 Sep 2022 13:02:19 -0700 Subject: [PATCH 2/4] Fix lint --- wallet/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wallet/README.md b/wallet/README.md index ae5123aca2ba0..5f5b92e80af86 100644 --- a/wallet/README.md +++ b/wallet/README.md @@ -1,7 +1,6 @@ # Sui Wallet - -A Chrome (v88+) extension wallet for [Sui](https://sui.io). +A Chrome (v88+) extension wallet for [Sui](https://sui.io). test change # Set Up From ae2ad82998ead9a1059c7fe08f85016740400729 Mon Sep 17 00:00:00 2001 From: Jordan Gensler Date: Fri, 23 Sep 2022 13:31:34 -0700 Subject: [PATCH 3/4] Update workflow to hopefully work --- .github/workflows/wallet-ext-comment.yml | 21 +++++++++++++++------ .github/workflows/wallet-ext-prs.yml | 1 - 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/wallet-ext-comment.yml b/.github/workflows/wallet-ext-comment.yml index 68d4f00ac4cf2..076d42a0ff5e6 100644 --- a/.github/workflows/wallet-ext-comment.yml +++ b/.github/workflows/wallet-ext-comment.yml @@ -15,24 +15,33 @@ jobs: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' steps: - - name: 'Download artifact' - uses: actions/github-script@v3.1.0 + - name: "Download artifact" + uses: actions/github-script@v6 + id: get-artifact with: + result-encoding: string script: | - var artifacts = await github.actions.listWorkflowRunArtifacts({ + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, - run_id: ${{github.event.workflow_run.id }}, + run_id: context.payload.workflow_run.id, }); - var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { return artifact.name == "wallet-extension" })[0]; + if (!matchArtifact) { + return ''; + } + + return matchArtifact.archive_download_url; + - name: Comment PR uses: thollander/actions-comment-pull-request@v1 + if: steps.get-artifact.outputs.result != '' with: comment_includes: "💳 Wallet Extension" message: | - 💳 Wallet Extension has been built, you can download the packaged extension here: https://github.com/MystenLabs/sui/actions/runs/${{ github.run_id }}#artifacts + 💳 Wallet Extension has been built, you can download the packaged extension here: ${{steps.get-artifact.outputs.result}} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/wallet-ext-prs.yml b/.github/workflows/wallet-ext-prs.yml index 879e6472f3818..48d8c87031813 100644 --- a/.github/workflows/wallet-ext-prs.yml +++ b/.github/workflows/wallet-ext-prs.yml @@ -44,7 +44,6 @@ jobs: working-directory: ${{env.working-directory}} run: pnpm pack:zip - uses: actions/upload-artifact@v2 - if: always() with: name: wallet-extension path: wallet/web-ext-artifacts/* From c3770159a76e2a1cff9850dd871356e8310dab76 Mon Sep 17 00:00:00 2001 From: Jordan Gensler Date: Fri, 23 Sep 2022 13:35:33 -0700 Subject: [PATCH 4/4] Remove test change --- wallet/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallet/README.md b/wallet/README.md index 5f5b92e80af86..2a435945c4f9b 100644 --- a/wallet/README.md +++ b/wallet/README.md @@ -1,6 +1,6 @@ # Sui Wallet -A Chrome (v88+) extension wallet for [Sui](https://sui.io). test change +A Chrome (v88+) extension wallet for [Sui](https://sui.io). # Set Up