-
Notifications
You must be signed in to change notification settings - Fork 16
114 lines (99 loc) · 3.61 KB
/
eslintcheck.yaml
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: ESLint Check
on:
workflow_dispatch:
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
permissions:
pull-requests: write
contents: write
jobs:
lint-and-deploy:
name: Run ESLint check and deploy Preview
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: setup NodeJS for Build
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- name: install all Dependencies
run: npm ci
- name: Run security audit
run: npm audit
continue-on-error: true
id: security-audit
- name: Check for security vulnerabilities
if: steps.security-audit.outcome == 'failure'
run: |
echo "Security vulnerabilities found. Failing the workflow."
exit 1
- name: Run ESLint test
run: npm run lint:strict
continue-on-error: true
id: eslint
- name: block PR if ESLint fails
continue-on-error: true
if: steps.eslint.outcome == 'failure'
uses: actions/github-script@v6
with:
github-token: ${{ github.tokens }}
script: |
github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
event: 'REQUEST_CHANGES',
body: 'ESLint check failed. Please fix all linting issues (including warnings) before merging.'
})
- name: check for ESLint result
if: steps.eslint.outcome == 'failure'
run: |
echo "ESLint found issues. Failing the workflow."
exit 1
- name: build Project from React Files
run: npm run build
- name: create _redirects file
run: echo "/healthcare/* /index.html 200" > build/_redirects
- name: deploy to netlify
continue-on-error: true
id: netlify-deploy
uses: nwtgck/[email protected]
with:
publish-dir: './build'
production-branch: main
github-token: ${{ secrets.VAI }} # GITHUB_TOKEN and VAI throwing resource-inaccessible error
deploy-message: "FROM GITHUB_ACTIONS"
enable-pull-request-comment: true
enable-commit-comment: false
overwrites-pull-request-comment: false
alias: healthcare-deploy-preview-${{ github.event.number }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
# - name: Comment URL preview on PR
# continue-on-error: true
# uses: actions/github-script@v7
# with:
# script: |
# const deployUrl = '${{ steps.netlify-deploy.outputs.deploy-url }}';
# const issueNumber = context.issue.number;
# const username = context.actor;
# if (deployUrl) {
# github.rest.issues.createComment({
# issue_number: issueNumber,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: `WORKFLOW BOT: @${username} your preview URL has been generated: ${deployUrl}`
# });
# } else {
# github.rest.issues.createComment({
# issue_number: issueNumber,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: `WORKFLOW BOT: @${username} your preview URL not deployed`
# });
# }