Skip to content

Commit 64b0575

Browse files
committed
initial commit
0 parents  commit 64b0575

114 files changed

Lines changed: 10864 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
# Controls when the workflow will run
4+
on: [push, workflow_dispatch]
5+
6+
env:
7+
SPECTRAL_DSN: ${{ secrets.SPECTRAL_DSN }}
8+
9+
jobs:
10+
ubuntu:
11+
name: Spectral ubuntu
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Install Spectral
16+
uses: ./
17+
with:
18+
spectral-dsn: ${{ secrets.SPECTRAL_DSN }}
19+
- name: Spectral Scan
20+
run: spectral scan
21+
macOS:
22+
name: Spectral macOS
23+
runs-on: macos-latest
24+
steps:
25+
- uses: actions/checkout@v2
26+
- name: Install Spectral
27+
uses: ./
28+
with:
29+
spectral-dsn: ${{ secrets.SPECTRAL_DSN }}
30+
- name: Spectral Scan
31+
run: spectral scan
32+
windows:
33+
name: Spectral windows
34+
runs-on: windows-latest
35+
steps:
36+
- uses: actions/checkout@v2
37+
- name: Install Spectral
38+
uses: ./
39+
with:
40+
spectral-dsn: ${{ secrets.SPECTRAL_DSN }}
41+
- name: Spectral Scan
42+
run: spectral.exe scan

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 SpectralOps
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<p>
2+
<br/>
3+
<br/>
4+
<p align="center">
5+
<a href="http://spectralops.io">
6+
<img alt="SpectralOps logo" src="./logo.svg" width="300"/>
7+
</a>
8+
</p>
9+
<p align="center">
10+
<img src="https://github.com/spectralops/spectral-github-action/actions/workflows/main.yml/badge.svg"/>
11+
<img src="https://img.shields.io/badge/license-MIT-brightgreen"/>
12+
</p>
13+
<h1>Spectral Scan</h1>
14+
</p>
15+
16+
# Install Spectral Scan action
17+
18+
Spectral Scan is a single self-contained binary, that's easy to get and use. This action installs the latest Spectral version into your PATH.
19+
20+
## Example usage
21+
22+
Include this Action as a step in your workflow:
23+
24+
```
25+
uses: spectral/spectral-action@v1
26+
with:
27+
spectral-dsn: ${{ secrets.SPECTRAL_DSN }}
28+
```
29+
30+
You can see an example of this Action [here](https://github.com/SpectralOps/spectral-github-action/tree/main/.github/workflows/main.yml)
31+
32+
## Configuration
33+
34+
You'll need to provide Spectral dsn. You can do so via the `SPECTRAL_DSN` environment variable. In the below example, the Spectral dsn is retrieved from [GitHub secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets).
35+
36+
```yaml
37+
name: Example action
38+
39+
on: [push]
40+
41+
env:
42+
SPECTRAL_DSN: ${{ secrets.SPECTRAL_DSN }}
43+
44+
jobs:
45+
my-job:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v2
49+
- name: Install Spectral
50+
uses: spectral/spectral-action@v1
51+
with:
52+
spectral-dsn: ${{ secrets.SPECTRAL_DSN }}
53+
- name: Spectral Scan
54+
run: spectral scan
55+
```
56+
57+
### How to Contribute
58+
59+
We welcome [issues](https://github.com/SpectralOps/spectral-github-action/issues) to and [pull requests](https://github.com/SpectralOps/spectral-github-action/pulls) against this repository!
60+
61+
## License
62+
63+
This project is licensed under the MIT License. See [LICENSE](LICENSE) for further details.

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "Spectral Scan"
2+
description: "Install Spectral into your PATH"
3+
inputs:
4+
spectral-dsn:
5+
description: "Your Spectral DSN"
6+
required: true
7+
branding:
8+
icon: "download"
9+
color: "purple"
10+
runs:
11+
using: "node12"
12+
main: "index.js"

index.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const core = require('@actions/core');
2+
const io = require('@actions/io');
3+
const tc = require('@actions/tool-cache');
4+
5+
const workspace = process.env.GITHUB_WORKSPACE;
6+
const binDir = `${workspace}/bin`;
7+
8+
main().catch(error => {
9+
core.setFailed(error)
10+
})
11+
12+
async function main() {
13+
switch (process.platform) {
14+
case 'win32':
15+
await installExecutable(binDir)
16+
break;
17+
case 'linux':
18+
await installZip(binDir, process.platform)
19+
break;
20+
case 'darwin':
21+
await installZip(binDir, 'mac')
22+
break;
23+
default:
24+
break;
25+
}
26+
27+
await core.addPath(binDir)
28+
}
29+
30+
async function downloadTool(platform) {
31+
const spectralDsn = core.getInput('spectral-dsn')
32+
const url = `${spectralDsn}/latest/dl/${platform}`
33+
return await tc.downloadTool(url);
34+
}
35+
36+
async function installZip(path, platform) {
37+
await io.mkdirP(path);
38+
const downloadPath = await downloadTool(platform)
39+
await tc.extractTar(downloadPath, path)
40+
}
41+
42+
async function installExecutable(path) {
43+
await io.mkdirP(path);
44+
const downloadPath = await downloadTool('exe')
45+
await io.mv(downloadPath, `${path}/spectral.exe`)
46+
}

0 commit comments

Comments
 (0)