-
Notifications
You must be signed in to change notification settings - Fork 28
194 lines (194 loc) · 8.11 KB
/
pub-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
190
191
192
193
194
name: Publish Docker images
env:
DOCKERHUB_REPOSITORY: nuwcdivnpt/stig-manager
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'api/source/**'
- 'client/src/**'
- 'docs/**'
- 'Dockerfile'
- '.github/workflows/build-client.yml'
- '.github/workflows/build-docs.yml'
- '.github/workflows/pub-docker.yml'
tags:
- 1.**
jobs:
build-client:
uses: nuwcdivnpt/stig-manager/.github/workflows/build-client.yml@main
build-docs:
uses: nuwcdivnpt/stig-manager/.github/workflows/build-docs.yml@main
build-push-alpine:
name: Build and push from Alpine base
needs:
- build-client
- build-docs
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Download client distribution
uses: actions/download-artifact@v4
with:
name: client-dist
path: ./client/dist
- name: Download documentation
uses: actions/download-artifact@v4
with:
name: docs-build
path: ./docs/_build/html
- name: Get repository metadata
id: repo
uses: actions/github-script@v7
with:
script: |
const repo = await github.rest.repos.get(context.repo)
return repo.data
- name: Prepare variables
id: prep
run: |
DOCKER_IMAGE=${{ env.DOCKERHUB_REPOSITORY }}
BRANCH=$(git symbolic-ref --short HEAD)
SHA=$(git rev-parse --short=10 HEAD)
DESCRIBE=$(git describe --tags)
TAG=$(git describe --tags --abbrev=0)
TAGS=${DOCKER_IMAGE}:latest
[[ ${{ github.ref_type }} == "tag" ]] && TAGS="$TAGS,${DOCKER_IMAGE}:${{ github.ref_name }}"
echo "version=${TAG}" >> $GITHUB_OUTPUT
echo "sha=${SHA}" >> $GITHUB_OUTPUT
echo "tab=${TAG}" >> $GITHUB_OUTPUT
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "describe=${DESCRIBE}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # pin@v2
- name: Login to DockerHub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # pin@v2
with:
username: ${{ secrets.DOCKERHUB_ORG_OWNER_USERNAME }}
password: ${{ secrets.DOCKERHUB_ORG_OWNER_PW }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # pin@v3
with:
context: .
file: ./Dockerfile
push: true
build-args: |
COMMIT_BRANCH=${{ steps.prep.outputs.branch }}
COMMIT_SHA=${{ steps.prep.outputs.sha }}
COMMIT_TAG=${{ steps.prep.outputs.tag }}
COMMIT_DESCRIBE=${{ steps.prep.outputs.describe }}
tags: ${{ steps.prep.outputs.tags }}
labels: |
stig-manager.last-migration.mysql=1.2.1
org.opencontainers.image.title=${{ fromJson(steps.repo.outputs.result).name }}
org.opencontainers.image.description=${{ fromJson(steps.repo.outputs.result).description }}
org.opencontainers.image.url=${{ fromJson(steps.repo.outputs.result).html_url }}
org.opencontainers.image.source=${{ fromJson(steps.repo.outputs.result).clone_url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ steps.prep.outputs.describe }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@202973a37c8a723405c0c5f0a71b6d99db470dae # pin@v3
with:
username: ${{ secrets.DOCKERHUB_ORG_OWNER_USERNAME }}
password: ${{ secrets.DOCKERHUB_ORG_OWNER_PW }}
repository: ${{ env.DOCKERHUB_REPOSITORY }}
short-description: An API and Web client for managing STIG assessments.
readme-filepath: ./docs/the-project/DockerHub_Readme.md
build-push-ironbank:
name: Build and push from Iron Bank base
needs:
- build-client
- build-docs
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Download client distribution
uses: actions/download-artifact@v4
with:
name: client-dist
path: ./client/dist
- name: Download documentation
uses: actions/download-artifact@v4
with:
name: docs-build
path: ./docs/_build/html
- name: Get repository metadata
id: repo
uses: actions/github-script@v7
with:
script: |
const repo = await github.rest.repos.get(context.repo)
return repo.data
- name: Prepare variables
id: prep
run: |
DOCKER_IMAGE=${{ env.DOCKERHUB_REPOSITORY }}
BRANCH=$(git symbolic-ref --short HEAD)
SHA=$(git rev-parse --short=10 HEAD)
DESCRIBE=$(git describe --tags)
TAG=$(git describe --tags --abbrev=0)
TAGS="${DOCKER_IMAGE}:latest-ironbank"
[[ ${{ github.ref_type }} == "tag" ]] && TAGS="$TAGS,${DOCKER_IMAGE}:${{ github.ref_name }}-ironbank"
echo "version=${TAG}" >> $GITHUB_OUTPUT
echo "sha=${SHA}" >> $GITHUB_OUTPUT
echo "tab=${TAG}" >> $GITHUB_OUTPUT
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "describe=${DESCRIBE}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # pin@v2
- name: Login to DockerHub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # pin@v2
with:
username: ${{ secrets.DOCKERHUB_ORG_OWNER_USERNAME }}
password: ${{ secrets.DOCKERHUB_ORG_OWNER_PW }}
- name: Login to Iron Bank
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # pin@v2
with:
registry: registry1.dso.mil
username: ${{ secrets.IRONBANK_USERNAME }}
password: ${{ secrets.IRONBANK_CLI_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # pin@v3
with:
context: .
file: ./Dockerfile
push: true
build-args: |
BASE_IMAGE=registry1.dso.mil/ironbank/opensource/nodejs/nodejs18:18.18
COMMIT_BRANCH=${{ steps.prep.outputs.branch }}
COMMIT_SHA=${{ steps.prep.outputs.sha }}
COMMIT_TAG=${{ steps.prep.outputs.tag }}
COMMIT_DESCRIBE=${{ steps.prep.outputs.describe }}
tags: ${{ steps.prep.outputs.tags }}
labels: |
stig-manager.last-migration.mysql=1.2.1
org.opencontainers.image.title=${{ fromJson(steps.repo.outputs.result).name }}
org.opencontainers.image.description=${{ fromJson(steps.repo.outputs.result).description }}
org.opencontainers.image.url=${{ fromJson(steps.repo.outputs.result).html_url }}
org.opencontainers.image.source=${{ fromJson(steps.repo.outputs.result).clone_url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ steps.prep.outputs.describe }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}