Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
2wheeh committed Feb 15, 2024
1 parent e9aa32f commit 7ff1f81
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 11 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ui-comment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Comment the storybook preview url

on:
workflow_run:
workflows: ['UI Test']
types:
- completed

jobs:
upload:
runs-on: ubuntu-22.04
if: >
github.event.workflow_run.event == 'pull_request'
steps:
- name: 'Download artifact'
uses: actions/[email protected]
with:
script: |
const artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow._run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
const download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{ github.workspace }}/pr.zip', Buffer.from(download.data))
- run: unzip pr.zip

- name: Comment on PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const url = fs.readFileSync('./URL');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 Storybook preview: [${url}](${url})`
});
25 changes: 14 additions & 11 deletions .github/workflows/ui-test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: UI Test

on:
pull_request_target:
pull_request:
branches:
- main
- 'develop'
Expand Down Expand Up @@ -88,17 +88,20 @@ jobs:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1

- name: Comment
uses: actions/github-script@v7
# - name: Save PR number
# run: |
# mkdir -p ./pr
# echo ${{ github.event.number }} > ./pr/NR

- name: Save Storybook preview url
run: |
mkdir -p ./pr
echo ${{ steps.deploy-preview.outputs.deploy-url }} > ./pr/URL
- uses: actions/upload-artifact@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🚀 Storybook preview: [${{ steps.deploy-preview.outputs.deploy-url }}](${{ steps.deploy-preview.outputs.deploy-url }})'
})
name: pr
path: pr/

interaction-test:
runs-on: ubuntu-22.04
Expand Down

0 comments on commit 7ff1f81

Please sign in to comment.