Skip to content

Commit ab79612

Browse files
committed
[upgrade] to latest workflow
1 parent bad9577 commit ab79612

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

.github/workflows/docker.yml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ on:
1616
required: false
1717
default: 'ubuntu-22.04'
1818

19+
build:
20+
description: 'set WORKFLOW_BUILD'
21+
required: false
22+
default: 'true'
23+
1924
release:
2025
description: 'set WORKFLOW_GITHUB_RELEASE'
2126
required: false
@@ -45,7 +50,6 @@ jobs:
4550
actions: read
4651
contents: write
4752
packages: write
48-
security-events: write
4953

5054
steps:
5155
- name: init / checkout
@@ -154,6 +158,11 @@ jobs:
154158
docker.app[arg] = opt.input.etc.build.args[arg];
155159
}
156160
}
161+
if(opt.dot?.build?.args){
162+
for(const arg in opt.dot.build.args){
163+
docker.app[arg] = opt.dot.build.args[arg];
164+
}
165+
}
157166
const arguments = [];
158167
for(const argument in docker.app){
159168
arguments.push(`APP_${argument.toUpperCase()}=${docker.app[argument]}`);
@@ -171,6 +180,7 @@ jobs:
171180
core.exportVariable('DOCKER_IMAGE_ARGUMENTS', arguments.join("\r\n"));
172181
core.exportVariable('DOCKER_IMAGE_DOCKERFILE', opt.input?.etc?.dockerfile || 'arch.dockerfile');
173182
183+
core.exportVariable('WORKFLOW_BUILD', (opt.input?.build === undefined) ? false : opt.input.build);
174184
core.exportVariable('WORKFLOW_CREATE_RELEASE', (opt.input?.release === undefined) ? false : opt.input.release);
175185
core.exportVariable('WORKFLOW_CREATE_README', (opt.input?.readme === undefined) ? false : opt.input.readme);
176186
core.exportVariable('WORKFLOW_GRYPE_FAIL_ON_SEVERITY', (opt.dot?.grype?.fail === undefined) ? true : opt.dot.grype.fail);
@@ -205,14 +215,17 @@ jobs:
205215
password: ${{ secrets.QUAY_TOKEN }}
206216

207217
- name: docker / setup qemu
218+
if: env.WORKFLOW_BUILD == 'true'
208219
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a
209220

210221
- name: docker / setup buildx
222+
if: env.WORKFLOW_BUILD == 'true'
211223
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5
212224
with:
213225
driver-opts: network=host
214226

215227
- name: docker / build & push & tag grype
228+
if: env.WORKFLOW_BUILD == 'true'
216229
id: docker-build
217230
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d
218231
with:
@@ -228,6 +241,7 @@ jobs:
228241
${{ env.DOCKER_CACHE_GRYPE }}
229242
230243
- name: grype / scan
244+
if: env.WORKFLOW_BUILD == 'true'
231245
id: grype
232246
uses: anchore/scan-action@dc6246fcaf83ae86fcc6010b9824c30d7320729e
233247
with:
@@ -239,7 +253,7 @@ jobs:
239253
cache-db: true
240254

241255
- name: grype / fail
242-
if: failure() || steps.grype.outcome == 'failure'
256+
if: env.WORKFLOW_BUILD == 'true' && (failure() || steps.grype.outcome == 'failure')
243257
uses: anchore/scan-action@dc6246fcaf83ae86fcc6010b9824c30d7320729e
244258
with:
245259
image: ${{ env.DOCKER_CACHE_GRYPE }}
@@ -250,6 +264,7 @@ jobs:
250264
cache-db: true
251265

252266
- name: docker / build & push
267+
if: env.WORKFLOW_BUILD == 'true'
253268
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d
254269
with:
255270
context: .
@@ -338,27 +353,27 @@ jobs:
338353
339354
340355
# README
341-
- name: github / checkout master
356+
- name: github / checkout HEAD
342357
continue-on-error: true
343-
run: |
344-
git pull
345-
git checkout master
358+
run: |
359+
git checkout HEAD
346360
347361
- name: docker / setup comparison images
348362
if: env.WORKFLOW_CREATE_COMPARISON == 'true'
349363
continue-on-error: true
350364
run: |
351-
docker image prune -af
352365
docker image pull ${{ env.WORKFLOW_CREATE_COMPARISON_IMAGE }}
366+
docker image ls --filter "reference=${{ env.WORKFLOW_CREATE_COMPARISON_IMAGE }}" --format json | jq --raw-output '.Size' &> ./comparison.size0.log
367+
353368
docker image pull ${{ env.WORKFLOW_CREATE_COMPARISON_FOREIGN_IMAGE }}
354-
docker image ls &> ./docker.image.ls
355-
echo "${PWD}"
356-
cat ./docker.image.ls
369+
docker image ls --filter "reference=${{ env.WORKFLOW_CREATE_COMPARISON_FOREIGN_IMAGE }}" --format json | jq --raw-output '.Size' &> ./comparison.size1.log
370+
371+
docker run --entrypoint "/bin/sh" --rm ${{ env.WORKFLOW_CREATE_COMPARISON_FOREIGN_IMAGE }} -c id &> ./comparison.id.log
357372
358373
- name: github / create README.md
359374
id: github-readme
360375
continue-on-error: true
361-
if: env.WORKFLOW_CREATE_README == 'true' && steps.docker-build.outcome == 'success'
376+
if: env.WORKFLOW_CREATE_README == 'true'
362377
uses: 11notes/action-docker-readme@v1
363378
# WHY IS THIS ACTION NOT SHA256 PINNED? SECURITY MUCH?!?!?!
364379
# ---------------------------------------------------------------------------------
@@ -384,17 +399,6 @@ jobs:
384399
short_description: ${{ env.DOCKER_IMAGE_DESCRIPTION }}
385400
readme_file: 'README_NONGITHUB.md'
386401

387-
- name: quay / push README.md to quay
388-
continue-on-error: true
389-
if: steps.github-readme.outcome == 'success' && hashFiles('README_NONGITHUB.md') != ''
390-
uses: christian-korneck/update-container-description-action@d36005551adeaba9698d8d67a296bd16fa91f8e8
391-
env:
392-
DOCKER_APIKEY: ${{ secrets.QUAY_TOKEN }}
393-
with:
394-
destination_container_repo: quay.io/${{ env.DOCKER_IMAGE_NAME }}
395-
provider: quay
396-
readme_file: 'README_NONGITHUB.md'
397-
398402
- name: github / commit & push
399403
continue-on-error: true
400404
if: steps.github-readme.outcome == 'success' && hashFiles('README.md') != ''
@@ -408,8 +412,8 @@ jobs:
408412
if [ -f LICENSE ]; then
409413
git add LICENSE
410414
fi
411-
git commit -m "auto update README.md"
412-
git push
415+
git commit -m "github-actions[bot]: update README.md"
416+
git push origin HEAD:master
413417
414418
415419

0 commit comments

Comments
 (0)