-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (54 loc) · 1.75 KB
/
main.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
name: JavaScript Landing Page Test Runner by Codebase Mentor
on:
workflow_call:
inputs:
pr_number:
description: 'The pull request number'
required: true
type: number
head_sha:
description: 'The SHA of the PR branch'
required: true
type: string
secrets:
GH_TOKEN:
description: 'GitHub token for performing reviews'
required: true
permissions: write-all
jobs:
check_is_signed_up:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
status: [200]
steps:
- name: Set up environment variables
env:
USER_ID: ${{ github.event.sender.id }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
echo "USER_ID=${USER_ID}" >> $GITHUB_ENV
echo "GH_TOKEN=${GH_TOKEN}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Call API endpoint
if: ${{ matrix.status == 200 }}
run: |
status_code=$(curl -s -o /dev/null -w "%{http_code}" -X POST -d "${USER_ID}" https://jobsim-pr-user-check.deno.dev)
if [ $status_code -ne 200 ]; then
gh pr review ${{ inputs.pr_number }} --comment --body "It looks like your GitHub account is not registered with JobSimulator.Dev. Please sign up at https://www.jobsimulator.dev to have your PR be tested automatically. Once you've signed up, close and open your PR to start the tests. Thanks!"
exit 1
fi
test:
runs-on: ubuntu-latest
needs: check_is_signed_up
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.head_sha }}
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- name: Run Tests
run: node test.js