-
Notifications
You must be signed in to change notification settings - Fork 18
189 lines (168 loc) · 7.42 KB
/
docker.yml
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
###############################################################################
# _ _ _ _ _____ _
# | | | | | | | | | __ \(_)
# | | ___ | |__ _ __ | |_| |__ ___ | |__) |_ _ __ _ __ ___ _ __
# _ | |/ _ \| '_ \| '_ \ | __| '_ \ / _ \ | _ /| | '_ \| '_ \ / _ \ '__|
# | |__| | (_) | | | | | | | | |_| | | | __/ | | \ \| | |_) | |_) | __/ |
# \____/ \___/|_| |_|_| |_| \__|_| |_|\___| |_| \_\_| .__/| .__/ \___|_|
# | | | |
# |_| |_|
#
# Copyright (c) 2021-2023 Claudio André <claudioandre.br at gmail.com>
#
# This program comes with ABSOLUTELY NO WARRANTY; express or implied.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, as expressed in version 2, seen at
# http://www.gnu.org/licenses/gpl-2.0.html
###############################################################################
# GitHub Action to build John the Ripper's Docker image
# More info at https://github.com/openwall/john-packages
---
name: Docker
"on":
push:
branches: [docker]
workflow_dispatch:
inputs:
VERSION_NAME:
description: "The software version name"
required: true
default: "1.9.0-jumbo-1+"
tag:
description: "The image tag"
required: true
type: choice
default: "bleeding"
options:
- bleeding
- latest
extra:
description: "Add another image tag"
type: string
push:
description: "Push the image to Docker registry?"
type: boolean
default: false
env:
REPO: ghcr.io/${{ github.repository_owner }}/john
permissions: read-all
jobs:
build:
name: Build Docker image
runs-on: ubuntu-latest
permissions:
attestations: write
id-token: write
packages: write
outputs:
image: ${{ env.REPO }}:${{ github.event.inputs.tag }}
digest: ${{ steps.build-and-push.outputs.digest }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
archive.ubuntu.com:80
auth.docker.io:443
developer.download.nvidia.com:443
fulcio.sigstore.dev:443
ghcr.io:443
github.com:443
objects.githubusercontent.com:443
ports.ubuntu.com:80
production.cloudflare.docker.com:443
raw.githubusercontent.com:443
registry-1.docker.io:443
rekor.sigstore.dev:443
security.ubuntu.com:80
- name: Check out the repo
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Get data
id: data
run: |
image_name="${{ env.REPO }}:${{ github.event.inputs.tag || 'test' }}"
version="1.9.$(date +%Y%m%d)"
image_tags="${image_name},"
image_tags+="${image_name}_J${{ github.run_number }},"
image_tags+="${image_name}_${version}"
if [[ -n "${{ github.event.inputs.extra }}" ]]; then
image_tags+=",${{ env.REPO }}:${{ github.event.inputs.extra }}"
fi
#TODO: edit before release (JUMBO_RELEASE)
{
echo "now=$(date -u)"
echo "revision=$(git rev-parse --short=7 HEAD 2>/dev/null)"
echo "version=$version"
echo "image_tags=$image_tags"
} >> "$GITHUB_OUTPUT"
- name: Docker meta
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.REPO }}:${{ github.event.inputs.tag }}
labels: |
org.opencontainers.image.authors="Claudio André <claudioandre.br at gmail com>"
software="John the Ripper ${{ github.event.inputs.VERSION_NAME }}"
org.opencontainers.image.description="John the Ripper is an Open Source password security auditing and password recovery tool. See https://www.openwall.com/john/"
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- name: Log in to GitHub Container Registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
id: build-and-push
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
context: "${{ github.workspace }}/deploy/docker"
platforms: linux/amd64,linux/arm64
push: ${{
(github.event.inputs.push || false)
}}
build-args: |
TYPE=ALL
RELEASE_COMMIT=97a023b97d3d4b2cbdce341dc37b3932a3b5138f
tags: ${{ steps.data.outputs.image_tags }}
labels: |
${{ steps.meta.outputs.labels }}
outputs: "type=image,name=target,\
annotation-index.software=John the Ripper ${{ github.event.inputs.VERSION_NAME }},\
annotation-index.org.opencontainers.image.authors=Claudio André <claudioandre.br at gmail com>,\
annotation-index.org.opencontainers.image.created=${{ steps.data.outputs.now }},\
annotation-index.org.opencontainers.image.description=John the Ripper is an Open Source password security auditing and password recovery tool. See https://www.openwall.com/john/,\
annotation-index.org.opencontainers.image.licenses=GPL-2.0,\
annotation-index.org.opencontainers.image.revision=${{ steps.data.outputs.revision }},\
annotation-index.org.opencontainers.image.source=https://github.com/openwall/john-packages.git,\
annotation-index.org.opencontainers.image.title=John the Ripper CE Auditing Tool,\
annotation-index.org.opencontainers.image.url=https://www.openwall.com/john,\
annotation-index.org.opencontainers.image.vendor=Openwall,\
annotation-index.org.opencontainers.image.version=${{ steps.data.outputs.version }}"
- name: Upload attestation
uses: actions/attest-build-provenance@173725a1209d09b31f9d30a3890cf2757ebbff0d # v1.1.2
if: ${{ github.event.inputs.push == 'true' }}
with:
subject-name: ${{ env.REPO }}:${{ github.event.inputs.tag }}
subject-digest: ${{ steps.build-and-push.outputs.digest }}
provenance:
if: ${{ github.event.inputs.push == 'true' }}
needs: [build]
permissions:
actions: read # for detecting the GitHub Actions environment.
id-token: write # for creating OIDC tokens for signing.
packages: write # for uploading attestations.
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
image: ${{ needs.build.outputs.image }}
digest: ${{ needs.build.outputs.digest }}
registry-username: ${{ github.actor }}
secrets:
registry-password: ${{ secrets.GITHUB_TOKEN }}