Skip to content

Commit 5a45adf

Browse files
authored
feat: publish eol-scan image (#282)
1 parent 8ab1074 commit 5a45adf

File tree

4 files changed

+146
-8
lines changed

4 files changed

+146
-8
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,10 @@ jobs:
3939
needs: shellcheck
4040
strategy:
4141
fail-fast: false
42+
max-parallel: 3
4243
matrix:
43-
node:
44-
- 20
45-
- 22
46-
- 23
47-
platform:
48-
- ubuntu-latest
49-
- macos-latest
50-
- windows-latest
44+
node: [20, 22, 24]
45+
platform: [ubuntu-latest, macos-latest, windows-latest]
5146
name: "${{matrix.platform}} w/ Node.js ${{matrix.node}}.x"
5247
runs-on: ${{matrix.platform}}
5348
env:

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,48 @@ jobs:
4343
run: npm publish --provenance --access public
4444
env:
4545
NODE_AUTH_TOKEN: ${{ secrets.HD_CLI_NPM_TOKEN }}
46+
47+
publish-images:
48+
name: Publish Images
49+
runs-on: ubuntu-latest
50+
permissions:
51+
packages: write
52+
steps:
53+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
54+
- name: Parse tag
55+
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
56+
57+
- uses: docker/metadata-action@v5
58+
id: meta
59+
with:
60+
# Enable when we have Docker Hub set up
61+
images: |
62+
name=ghcr.io/herodevs/eol-scan
63+
name=docker.io/herodevs/eol-scan,enable=false
64+
tags: |
65+
type=sha,format=long
66+
type=raw,value=latest
67+
type=raw,value=${{ env.VERSION }}
68+
69+
- uses: docker/login-action@v3
70+
# Enable when we have Docker Hub set up
71+
if: ${{ false }}
72+
with:
73+
username: ${{ vars.DOCKERHUB_USERNAME }}
74+
password: ${{ secrets.DOCKERHUB_TOKEN }}
75+
76+
- uses: docker/login-action@v3
77+
with:
78+
registry: ghcr.io
79+
username: ${{ github.repository_owner }}
80+
password: ${{ secrets.GITHUB_TOKEN }}
81+
82+
- uses: docker/setup-buildx-action@v3
83+
- uses: docker/build-push-action@v6
84+
with:
85+
context: .
86+
file: ./ci/image.Dockerfile
87+
platforms: linux/amd64,linux/arm64
88+
push: true
89+
tags: ${{ steps.meta.outputs.tags }}
90+
labels: ${{ steps.meta.outputs.labels }}

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,95 @@ EXAMPLES
237237

238238
_See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/v4.6.45/src/commands/update.ts)_
239239
<!-- commandsstop -->
240+
241+
## CI/CD Usage
242+
243+
You can use `@herodevs/cli` in your CI/CD pipelines to automate EOL scanning.
244+
245+
### Using the Docker Image (recommended)
246+
247+
We provide a Docker image that's pre-configured to run EOL scans. Based on [`cdxgen`](https://github.com/CycloneDX/cdxgen),
248+
it contains build tools for most project types and will provide best results when generating an SBOM.
249+
250+
#### GitHub Actions
251+
252+
```yaml
253+
# .github/workflows/herodevs-eol-scan.yml
254+
name: HeroDevs EOL Scan
255+
256+
on:
257+
push:
258+
branches: [ main ]
259+
pull_request:
260+
branches: [ main ]
261+
262+
jobs:
263+
scan:
264+
runs-on: ubuntu-latest
265+
steps:
266+
- uses: actions/checkout@v4
267+
268+
- name: Run EOL Scan with Docker
269+
uses: docker://ghcr.io/herodevs/eol-scan
270+
with:
271+
args: "--json"
272+
```
273+
274+
#### GitLab CI/CD
275+
276+
```yaml
277+
eol-scan:
278+
image:
279+
name: "ghcr.io/herodevs/eol-scan"
280+
# Entrypoint or base command must be disabled due
281+
# to GitLab's execution mechanism and run manually
282+
entrypoint: [""]
283+
script: "npx @herodevs/cli@beta --json"
284+
```
285+
286+
### Using `npx`
287+
288+
You can use `npx` to run the CLI just like you'd run it locally.
289+
290+
> [!NOTE]
291+
> The development environment is expected to be ready to run the app. For best results,
292+
prefer [using the prebuilt image](#using-the-docker-image-recommended), but otherwise, prepare
293+
all requirements before the scan step.
294+
295+
#### GitHub Actions
296+
297+
```yaml
298+
# .github/workflows/herodevs-eol-scan.yml
299+
name: HeroDevs EOL Scan
300+
301+
on:
302+
push:
303+
branches: [ main ]
304+
pull_request:
305+
branches: [ main ]
306+
307+
jobs:
308+
scan:
309+
runs-on: ubuntu-latest
310+
steps:
311+
- uses: actions/checkout@v4
312+
- uses: actions/setup-node@v4
313+
with:
314+
node-version: '20'
315+
316+
- run: echo # Prepare environment, install tooling, perform setup, etc.
317+
318+
- name: Run EOL Scan
319+
run: npx @herodevs/cli@beta
320+
```
321+
322+
#### GitLab CI/CD
323+
324+
```yaml
325+
image: alpine
326+
327+
eol-scan:
328+
script:
329+
- echo # Prepare environment, install tooling, perform setup, etc.
330+
- npx @herodevs/cli@beta
331+
```

ci/image.Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM ghcr.io/cyclonedx/cdxgen:v11.4.3
2+
WORKDIR /app
3+
COPY . .
4+
RUN npm config set update-notifier false && npm config set loglevel error
5+
ENV NODE_NO_WARNINGS=1
6+
ENTRYPOINT ["npm", "exec", "-y", "@herodevs/cli@beta", "--", "scan:eol"]

0 commit comments

Comments
 (0)