-
Notifications
You must be signed in to change notification settings - Fork 5
75 lines (66 loc) · 2.23 KB
/
ci.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
name: CI
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
on:
push:
tags:
- '*'
branches:
- main
pull_request:
branches:
- main
jobs:
build-lint-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm run test:unit:ci
histoire-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- run: npm ci
- name: Get branch name (merge)
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: Get branch name (pull request)
if: github.event_name == 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
- name: Set HISTOIRE_BASE ENV
shell: bash
run: echo "HISTOIRE_BASE=$(echo /rennes3d-front/${BRANCH_NAME}/)" >> $GITHUB_ENV
- run: npm run story:build
- name: deploy to gh pages
run: |
echo "Deploying to directory: ${{env.BRANCH_NAME}}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
npx gh-pages --dist .histoire/dist/ --dest ${{env.BRANCH_NAME}} --remove "${{env.BRANCH_NAME}}/**" --no-history --dotfiles true --repo "https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git"
- name: add PR comment
uses: thollander/actions-comment-pull-request@v1
if: github.event_name == 'pull_request'
with:
message: 'GitHub Pages links:
* Histoires: https://camptocamp.github.io/rennes3d-front/${{env.BRANCH_NAME}}/'
comment_includes: 'GitHub Pages links:'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}