-
Notifications
You must be signed in to change notification settings - Fork 8
81 lines (69 loc) · 2.46 KB
/
feature-branch-deploy.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
# Based on https://evilmartians.com/chronicles/super-github-pages-budget-frontend-staging-with-storybook-and-more
name: Feature branch build and deploy
on:
push:
branches-ignore: [main]
pull_request:
types: [reopened]
branches-ignore: [main]
jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: Create branch name without text before first forward slash
run: |
RAW_BRANCH_NAME=${{ github.head_ref || github.ref_name }}
BRANCH_NAME=$(echo $RAW_BRANCH_NAME | sed 's/[^/]*\///')
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Check out
uses: actions/checkout@v4
- name: Create deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: demo-${{ env.BRANCH_NAME }}
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- uses: pnpm/action-setup@v4
name: Install pnpm
id: pnpm-install
with:
run_install: false
- name: Install dependencies
run: |
pnpm install
- name: Build
env:
STORYBOOK_BUILD_PATH: demo-${{ env.BRANCH_NAME }}
run: npm run build
- name: Create a version mark
run: |
touch ./storybook/dist/${{ github.sha }}.txt
- name: Pushing to pages branch
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: storybook/dist
target-folder: demo-${{ env.BRANCH_NAME }}
- name: Wait for GitHub Pages to be deployed
uses: mydea/action-wait-for-api@v2
with:
url: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/demo-${{ env.BRANCH_NAME }}/${{ github.sha }}.txt
expected-status: 200
timeout: 600
interval: 15
- name: Update deployment status
uses: bobheadxi/deployments@v1
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/demo-${{ env.BRANCH_NAME }}