Skip to content

Commit cd38496

Browse files
committed
✈️ setup-preflight-action
0 parents  commit cd38496

File tree

331 files changed

+50784
-0
lines changed

Some content is hidden

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

331 files changed

+50784
-0
lines changed

.github/workflows/test.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
preflight:
16+
["1.1.1", "1.0.0"]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Setup Preflight
22+
uses: ./
23+
with:
24+
preflight-version: ${{ matrix.preflight }}
25+
26+
- name: Test
27+
run: npm run test
28+
- name: Test curl-install deno with preflight
29+
if: runner.os == 'Linux'
30+
run: curl -fsSL https://deno.land/x/install/install.sh | preflight run sha256=561aa9d6533ca228c43e784bf9fe8b74c8bfd8c443386dbf20bb714ac2969ceb

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Dotan Nahum
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

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# :airplane: setup-preflight-action
2+
3+
Set up your GitHub Actions workflow with a specific version of [Preflight](https://github.com/spectralops/preflight).
4+
5+
## :bulb: Usage
6+
7+
Use the following to set up a `preflight` binary that's available in your workflow steps:
8+
9+
```yaml
10+
- name: Setup Preflight
11+
uses: spectralops/setup-preflight@v1
12+
```
13+
14+
And then, use preflight. Turn this risky business:
15+
16+
```yaml
17+
- name: Install w/curl
18+
run: curl -fsSL https://deno.land/x/install/install.sh | sh
19+
```
20+
21+
Into this 1-2 karate chop:
22+
23+
:one: On your mac (`brew tap spectralops/tap && brew install preflight`)
24+
25+
```
26+
$ curl -fsSL https://deno.land/x/install/install.sh | preflight create
27+
sha256=561aa9d6533ca228c43e784bf9fe8b74c8bfd8c443386dbf20bb714ac2969ceb
28+
```
29+
30+
:two: In your workflow (you now have `preflight` available):
31+
32+
```yaml
33+
- name: Install w/curl protected with Preflight
34+
run: curl -fsSL https://deno.land/x/install/install.sh | preflight run sha256=561aa9d6533ca228c43e784bf9fe8b74c8bfd8c443386dbf20bb714ac2969ceb
35+
```
36+
37+
38+
39+
40+
## :clipboard: Workflow
41+
42+
```yaml
43+
name: run with preflight
44+
on:
45+
push:
46+
branches:
47+
- master
48+
- main
49+
pull_request:
50+
51+
jobs:
52+
build:
53+
name: Build your code
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Clone repo
58+
uses: actions/checkout@master
59+
60+
61+
# set up preflight
62+
- name: Setup Preflight
63+
uses: spectralops/setup-preflight@v1
64+
65+
66+
- name: Install w/curl protected with Preflight
67+
run: curl -fsSL https://deno.land/x/install/install.sh | preflight run sha256=561aa9d6533ca228c43e784bf9fe8b74c8bfd8c443386dbf20bb714ac2969ceb
68+
69+
- name: do stuff
70+
run: echo stuff
71+
```

action.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Setup Preflight"
2+
description: "Setup Preflight by installing, downloading, and adding it to the path."
3+
author: "Spectral"
4+
branding:
5+
icon: "play-circle"
6+
color: "gray-dark"
7+
inputs:
8+
preflight-version:
9+
description: The Preflight version to install.
10+
default: "1.1.1"
11+
outputs:
12+
preflight-version:
13+
description: "The Preflight version that was installed."
14+
runs:
15+
using: "node12"
16+
main: "main.js"

main.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const process = require("process");
2+
const core = require("@actions/core");
3+
4+
const { install } = require("./src/install.js");
5+
6+
function exit(message) {
7+
core.setFailed(message);
8+
process.exit();
9+
}
10+
11+
async function main() {
12+
try {
13+
const ver = core.getInput("preflight-version");
14+
if (ver === null) {
15+
exit("The passed version is not valid.");
16+
}
17+
18+
const version = { version: ver }
19+
if (version === null) {
20+
exit("Could not resolve a version for the given range.");
21+
}
22+
23+
core.info(
24+
`Going to install version ${version.version}.`,
25+
);
26+
27+
await install(version);
28+
29+
core.setOutput("preflight-version", version.version);
30+
31+
core.info("Installation complete.");
32+
} catch (err) {
33+
core.setFailed(err);
34+
process.exit();
35+
}
36+
}
37+
38+
main();

node_modules/.bin/semver

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uuid

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/LICENSE.md

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/README.md

+147
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.d.ts

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)