generated from dsanders11/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (89 loc) · 3.39 KB
/
ci.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
94
95
name: Continuous Integration
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
jobs:
test-typescript:
name: TypeScript Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
cache: npm
- name: Install Dependencies
run: npm ci
- name: Check Format
run: npm run format:check
- name: Lint
run: npm run lint
- name: Test
run: npm run ci-test
test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest
needs: test-typescript
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Test Local Action (Single File Valid)
id: single-file-valid
uses: ./
with:
schema: https://json.schemastore.org/github-workflow.json
files: .github/workflows/ci.yml
- name: Test Local Action (Single File Not Valid)
id: single-file-not-valid
uses: ./
with:
# Use the wrong schema so it fails validation
schema: https://gist.githubusercontent.com/dsanders11/b17fd12c00fc44b487df66d61039398e/raw/f05a9c19d6662282b1576b268e5c3228befc4700/schema.json
files: .github/workflows/ci.yml
fail-on-invalid: false
- name: Test Local Action (Multiple File Valid)
id: multiple-file-valid
uses: ./
with:
schema: https://json.schemastore.org/github-workflow.json
files: .github/workflows/**.yml
- name: Test Local Action (Multiple File Not Valid)
id: multiple-file-not-valid
uses: ./
with:
# Use the wrong schema so it fails validation
schema: https://gist.githubusercontent.com/dsanders11/b17fd12c00fc44b487df66d61039398e/raw/f05a9c19d6662282b1576b268e5c3228befc4700/schema.json
files: .github/workflows/**.yml
fail-on-invalid: false
- name: Confirm Output
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const assert = require('node:assert');
assert.strictEqual(${{ steps.single-file-valid.outputs.valid }}, true, 'Expected output for single file valid to be true');
assert.strictEqual(${{ steps.single-file-not-valid.outputs.valid }}, false, 'Expected output for single file invalid to be false');
assert.strictEqual(${{ steps.multiple-file-valid.outputs.valid }}, true, 'Expected output for multiple file valid to be true');
assert.strictEqual(${{ steps.multiple-file-not-valid.outputs.valid }}, false, 'Expected output for multiple file invalid to be false');
release:
name: release
runs-on: ubuntu-latest
needs: test-action
if: github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}