Repository navigation
108 lines (97 loc) · 4.03 KB
/
Copy pathcontainer.yml
File metadata and controls
108 lines (97 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Build the demo dashboard into a container image and publish it to
# ghcr.io/eyalsec/vulnerable-javascript, with a signed build-provenance
# attestation, so it can be served locally with one `docker run`.
#
# Verify an image you pulled was built here:
# gh attestation verify oci://ghcr.io/eyalsec/vulnerable-javascript:latest -R EyalSec/vulnerable-javascript
name: Container image
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
workflow_dispatch:
permissions:
contents: read
env:
IMAGE: ghcr.io/eyalsec/vulnerable-javascript
jobs:
image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # push to ghcr.io
id-token: write # sign the attestation
attestations: write # store the attestation
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Image tags and labels
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.IMAGE }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,format=short
labels: |
org.opencontainers.image.title=vulnerable-javascript
org.opencontainers.image.description=A deliberately vulnerable retail dashboard, the demonstration target for es-chromium. Local use only.
org.opencontainers.image.url=https://eyalsec.com
org.opencontainers.image.vendor=EyalSec
org.opencontainers.image.licenses=MIT
# Pull requests build both architectures but publish nothing.
- name: Log in to ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: build
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
- name: Attest build provenance
if: github.event_name != 'pull_request'
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-name: ${{ env.IMAGE }}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true
# Run the published image and fetch the app and its catalogue, so a broken
# image fails here instead of in someone's terminal.
smoke:
if: github.event_name != 'pull_request'
needs: image
runs-on: ubuntu-latest
permissions:
packages: read # the package can be private until it is made public
steps:
- name: Log in to ghcr.io
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Start the image
run: |
docker run -d --name demo -p 127.0.0.1:8000:8000 "$IMAGE:sha-${GITHUB_SHA::7}"
for _ in $(seq 1 30); do curl -fs http://127.0.0.1:8000/ >/dev/null && exit 0; sleep 1; done
docker logs demo; exit 1
- name: The pages are served
run: |
curl -fs http://127.0.0.1:8000/ | grep -q Northwind
curl -fs http://127.0.0.1:8000/catalog.js >/dev/null
curl -fsI http://127.0.0.1:8000/ | grep -qi 'x-robots-tag: noindex'