Skip to content

Commit 91f0087

Browse files
committed
fix: explicit firewall-x modes
1 parent 0a8642c commit 91f0087

2 files changed

Lines changed: 71 additions & 14 deletions

File tree

README.md

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,59 @@ A GitHub Action for running [Socket.dev](https://socket.dev)
77
88
## Usage
99

10+
This action can run in multiple modes:
11+
12+
- [Socket Firewall: Free](#socket-firewall-free)
13+
- [Socket Firewall: Enterprise](#socket-firewall-enterprise)
14+
- Socket CLI: _Coming soon_
15+
1016
### Socket Firewall: Free
1117

12-
Downloads and installs [Socket Firewall: Free](https://github.com/SocketDev/sfw-free) in your GitHub Action job, making it available to use in subsequent steps.
18+
Downloads and installs [Socket Firewall: Free](https://github.com/SocketDev/sfw-free) edition in your GitHub Action job, making it available to use in subsequent steps.
19+
20+
```yaml
21+
on: push
22+
23+
jobs:
24+
safe-install:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: SocketDev/action@v1
31+
with:
32+
mode: firewall-free
33+
34+
# javascript / typescript
35+
- run: sfw npm install # or yarn, pnpm
36+
37+
# rust
38+
- run: sfw cargo fetch
39+
40+
# python
41+
- run: sfw pip install -r requirements.txt
42+
```
43+
44+
#### Inputs
45+
46+
| Input | Description | Required | Default |
47+
| ------------------ | ----------------------------------------------------- | -------- | -------------------- |
48+
| `firewall-version` | Specify the firewall version number | No | `latest` |
49+
| `job-summary` | Create a [job summary][job-summary] | No | `true` |
50+
| `use-cache` | Cache the Socket binaries (force download if `false`) | No | `true` |
51+
| `github-token` | GitHub API Token used for downloading binaries | No | `${{ github.token}}` |
52+
53+
#### Outputs
54+
55+
| Output | Description |
56+
| ---------------------- | ------------------------------------------ |
57+
| `firewall-path-report` | Path to the generated firewall report JSON |
58+
| `firewall-path-binary` | Path to the installed binary |
59+
60+
### Socket Firewall: Enterprise
61+
62+
Downloads and installs [Socket Firewall: Enterprise](https://github.com/SocketDev/firewall-release) edition in your GitHub Action job, making it available to use in subsequent steps as a wrapper.
1363

1464
```yaml
1565
on: push
@@ -23,7 +73,8 @@ jobs:
2373
2474
- uses: SocketDev/action@v1
2575
with:
26-
mode: firewall
76+
mode: firewall-enterprise
77+
socket-token: ${{ secrets.SOCKET_API_KEY }}
2778
2879
# javascript / typescript
2980
- run: sfw npm install # or yarn, pnpm
@@ -37,13 +88,12 @@ jobs:
3788

3889
#### Inputs
3990

40-
| Input | Description | Required | Default |
41-
| ------------------ | ------------------------------------------------------------ | -------- | -------------------- |
42-
| `mode` | Specify run mode (currently only supporting `firewall` mode) | Yes | `-` |
43-
| `firewall-version` | Specify the firewall version number | No | `latest` |
44-
| `job-summary` | Create a [job summary][job-summary] | No | `true` |
45-
| `use-cache` | Cache the Socket binaries (force download if `false`) | No | `true` |
46-
| `github-token` | GitHub API Token used for downloading binaries | No | `${{ github.token}}` |
91+
| Input | Description | Required | Default |
92+
| ------------------ | ----------------------------------------------------- | -------- | -------------------- |
93+
| `firewall-version` | Specify the firewall version number | No | `latest` |
94+
| `job-summary` | Create a [job summary][job-summary] | No | `true` |
95+
| `use-cache` | Cache the Socket binaries (force download if `false`) | No | `true` |
96+
| `github-token` | GitHub API Token used for downloading binaries | **YES** | `${{ github.token}}` |
4797

4898
#### Outputs
4999

@@ -53,3 +103,4 @@ jobs:
53103
| `firewall-path-binary` | Path to the installed binary |
54104

55105
[job-summary]: https://github.blog/news-insights/product-news/supercharging-github-actions-with-job-summaries
106+
[job-summary]: https://github.blog/news-insights/product-news/supercharging-github-actions-with-job-summaries

src/main.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,31 @@ const inputs = {
2525
jobSummary: core.getBooleanInput('job-summary')
2626
}
2727

28-
let edition = 'free'
29-
3028
if (inputs.tokenSocket) {
3129
// setup socket token as a secret env
3230
core.exportVariable('SOCKET_API_KEY', inputs.tokenSocket)
3331
core.setSecret(inputs.tokenSocket)
34-
35-
// use Enterprise Firewall
36-
edition = 'enterprise'
3732
}
3833

3934
core.debug(`Installing Socket Action in ${inputs.mode} mode`)
4035

4136
switch (inputs.mode) {
4237
case 'firewall': {
38+
const edition = inputs.tokenSocket ? 'enterprise' : 'free'
4339
await firewall({ edition, ...inputs })
4440
break
4541
}
4642

43+
case 'firewall-free': {
44+
await firewall({ edition: 'free', ...inputs })
45+
break
46+
}
47+
48+
case 'firewall-enterprise': {
49+
await firewall({ edition: 'enterprise', ...inputs })
50+
break
51+
}
52+
4753
// TODO
4854
// case 'cli': {
4955
// await cli()

0 commit comments

Comments
 (0)