[#171] Add auth context #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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})` | ||
}); |