forked from MatteoH2O1999/MatteoH2O1999.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (122 loc) · 3.7 KB
/
pull_request.yml
File metadata and controls
130 lines (122 loc) · 3.7 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Check pull request
on:
pull_request:
permissions:
pull-requests: write
contents: read
env:
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
NODE_VERSION: 18
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
clean:
name: Clean contribution if not authorized
runs-on: ubuntu-latest
outputs:
authorized: ${{ steps.emit.outputs.result }}
steps:
- name: Emit output
uses: actions/github-script@v6
id: emit
with:
github-token: ${{ github.token }}
script: |
const author = process.env['PR_AUTHOR']
let result
core.info(`Pull request author is ${author}`)
if (author === 'shamil-mubarakshin' || author === 'MatteoH2O1999' || author === 'dependabot[bot]'){
core.info('Author is allowed to contribute')
result = true
} else {
core.info('Author is not allowed to contribute')
core.info('Closing PR...')
result = false
}
return result
- name: Clean contribution
if: ${{ steps.emit.outputs.result == 'false' }}
uses: dessant/repo-lockdown@v3
with:
pr-comment: This repository is a personal website and as such it does not accept pull requests.
log-output: true
test:
name: Test website
runs-on: ubuntu-latest
if: ${{ needs.clean.outputs.authorized == 'true' }}
needs: clean
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install production and development dependencies
run: npm ci --include=dev
- name: Run tests
run: npm run test-ci
env:
FORCE_COLOR: 3
build:
name: Test build website
runs-on: ubuntu-latest
needs: clean
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install production dependencies
run: npm ci --omit=dev
- name: Test build with Nuxt
run: npm run generate
- name: Upload generated pages
uses: actions/upload-artifact@v3
with:
path: dist/
name: pages
retention-days: 1
screenshots:
name: Generate screenshots
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, macos-13]
fail-fast: false
needs: [build, test]
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Download generated pages
uses: actions/download-artifact@v3
with:
name: pages
path: dist
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install production and development dependencies
run: npm ci --include=dev
- name: Generate screenshots
id: screenshots
run: npm run screenshots
- name: Upload screenshots
if: ${{ steps.screenshots.outputs.screenshots != '' }}
uses: actions/upload-artifact@v3
with:
retention-days: 1
name: ${{ steps.screenshots.outputs.artifact_name }}
path: ${{ steps.screenshots.outputs.screenshots }}