-
Notifications
You must be signed in to change notification settings - Fork 90
94 lines (84 loc) · 2.88 KB
/
publish-storybook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Storybook Preview Publish
run-name: Storybook publish for ${{ github.event.workflow_run.head_branch }}
on:
workflow_run:
workflows: ["Build Storybook"]
types:
- completed
jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
pull-requests: write
statuses: write
name: Deploy Storybook to Cloudflare Pages
steps:
- name: Set initial commit status
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: "${{ github.event.workflow_run.head_commit.id }}",
state: "pending",
description: "Pending",
context: "Storybook"
})
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- name: Install dependencies
run: yarn
- name: "Download build artifact"
uses: actions/download-artifact@v4
with:
name: storybook-build
path: ./storybook-static
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Publish
uses: cloudflare/pages-action@v1
id: publish
with:
apiToken: ${{ secrets.CLOUDFLARE_SALT_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_SALT_ACCOUNT_ID }}
projectName: "saltdesignsystem-storybook"
directory: ./storybook-static
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref || github.ref_name }}
- name: Update deploy status (success)
uses: actions/github-script@v7
if: success()
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: "${{ github.event.workflow_run.head_commit.id }}",
state: "success",
description: "Successfully deployed",
context: "Storybook",
target_url: "${{ steps.publish.outputs.url }}"
});
- name: Update deploy status (failure)
uses: actions/github-script@v7
if: failure()
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: "${{ github.event.workflow_run.head_commit.id }}",
state: "error",
description: "Failed to deploy",
context: "Storybook",
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
});