-
Notifications
You must be signed in to change notification settings - Fork 10
77 lines (69 loc) · 1.89 KB
/
cicd.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
name: CI/CD
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
test-build:
name: Test & Build
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Install dependencies
run: npm ci
- name: test the code
run: npm test
- name: build the code
run: npm run build
- name: Deploying to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
- name: Build
env:
VITE_APP_PUBLIC_URL: /example-react-cicd/
# TODO: Run tests here
# TODO: Run build here
# TODO: Deploy to github pages
## TIP
## to conditionally run a job or a step use the if key.
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
## TIP
## deploy steps and permissions for the Github token needed to deploy to gh-pages
# permissions:
# contents: write
# steps:
# - name: Deploying to gh-pages
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./dist
## TIP:
## to deploy to GH pages, set this env var in the build step
# - name: Build
# env:
# VITE_APP_PUBLIC_URL: /<repo_name>/
## TIP:
## If you need to share files between jobs upload them in the repo and download them in the destination job
# - name: Uploading build files
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# uses: actions/upload-artifact@v2
# with:
# name: artifact
# path: ./dist
# - name: Downloading artifact
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# uses: actions/download-artifact@v2
# with:
# name: artifact
# path: ./dist