-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (78 loc) · 2.8 KB
/
actions.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
name: Workflow
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
build-project: #First Job is to check the code formatting, linting and build the project.
if: github.event.pull_request.draft == false
name: Run Prettier, Lint and Build Checks
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 18
- name: Install Dependencies
run: npm install
- name: Code Formatting Check #Runs Prettier Script
run: npm run prettier
- name: Linting Check #Runs ESLint Script
run: npm run lint
- name: Build #Build the project
run: npm run build
- name: Check Build Status
run: |
if [ $? -eq 0 ]; then
echo "Build successful!🎉"
else
echo "Build failed!"
exit 1
fi
chromatic-deployment: #Second Job is to deploy the project to Chromatic
if: github.event.pull_request.draft == false
name: Deploy Storybook to Chromatic
runs-on: ubuntu-latest # Operating System
# Job steps
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # 👈 Required to retrieve git history
- name: Install dependencies
run: npm install
# 👇 Adds Chromatic as a step in the workflow
- name: Publish to Chromatic
uses: chromaui/action@v1
# Chromatic GitHub Action options
with:
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
check-up-to-date:
name: Check if PR is up to date with the main branch
runs-on: ubuntu-latest
steps:
- name: Check PR Up-to-Date
id: check-pr
run: |
# Get the name of the current pull request branch
PR_BRANCH=$GITHUB_REF
# Set the target branch (the main branch)
BASE_BRANCH=main
# Update the main branch to ensure it's up to date
git fetch origin $BASE_BRANCH:$BASE_BRANCH
# Compare the PR branch with the main branch and list the differing files
DIFF_FILES=$(git diff --name-only $BASE_BRANCH..$PR_BRANCH)
if [[ -z $DIFF_FILES ]]; then
# No differences, the PR is up to date
echo "PR is up-to-date with the main branch."
else
# Differences detected, the PR is not up to date
echo "PR is not up-to-date with the main branch. The following files have changes:"
echo "$DIFF_FILES"
echo "Please update your branch and resolve any conflicts before merging."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}