65 lines
2.6 KiB
Markdown
65 lines
2.6 KiB
Markdown
# Get Images From Files Action
|
|
|
|
A reusable Gitea Action that extracts Docker image references from selected files in a repository. Duplicate refs are deduplicated. Use the list with `osv-scanner scan image <ref>` (or a loop in CI) to scan container images.
|
|
|
|
**Note:** Only fully-qualified refs (with registry, e.g. `docker.io/library/alpine:latest`, `gcr.io/distroless/static:nonroot@sha256:...`) are included; short refs like `alpine:latest` are omitted as their use is discouraged.
|
|
|
|
## Supported file formats
|
|
|
|
| Format | How images are extracted |
|
|
| ------ | ------------------------- |
|
|
| **Dockerfile** | `FROM` lines; the image ref is the last token (handles `FROM --platform=... <image>`). |
|
|
| **Kubernetes manifests** | Lines with `image:` (e.g. under `containers` / `initContainers`); the value is taken as the image ref. |
|
|
| **Docker Compose / Compose** | Same as Kubernetes: `image:` key under services. |
|
|
| **Helmfile values** | Pairs of `repository` and `tag` (both required) at the same indent; ref is `repository:tag`. A lone `tag` without `repository` is skipped. |
|
|
|
|
Other files are supported if they use one of these patterns (e.g. `image:` or `FROM`).
|
|
|
|
## Usage
|
|
|
|
### Basic Usage
|
|
|
|
```yaml
|
|
- name: Get Images From Files
|
|
uses: https://gitea.t000-n.de/t.behrendt/osv-scanner-actions/get-images-from-files@0.0.1
|
|
with:
|
|
files: |
|
|
- Dockerfile
|
|
- k8s/50_deployment.yaml
|
|
- dockers/compose.yaml
|
|
- values/traefik.yaml
|
|
```
|
|
|
|
### Complete Example
|
|
|
|
```yaml
|
|
name: Get Images From Files
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
get-images-from-files:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Get Images From Files
|
|
uses: https://gitea.t000-n.de/t.behrendt/osv-scanner-actions/get-images-from-files@0.0.1
|
|
with:
|
|
files: |
|
|
- Dockerfile
|
|
- k8s/50_deployment.yaml
|
|
- dockers/compose.yaml
|
|
- values/traefik.yaml
|
|
```
|
|
|
|
## Inputs
|
|
|
|
| Input | Description | Required | Default |
|
|
| --------- | ----------------------------------------- | -------- | -------- |
|
|
| `files` | Files to extract images from. Multiple files can be specified.. | Yes | |
|
|
|
|
## Outputs
|
|
|
|
| Output | Description |
|
|
| --------- | ----------------------------------------- |
|
|
| `images` | JSON array of extracted image reference strings (e.g. `["docker.io/library/alpine:latest","gcr.io/distroless/static:nonroot@sha256:..."]`). Only fully-qualified refs (with registry) are included; short refs like `alpine:latest` are omitted. Parse with `jq` (e.g. `jq -r '.[]'`) to iterate. |
|