Skip to content

feat: add github workflow #2

feat: add github workflow

feat: add github workflow #2

Workflow file for this run

name: 'AdoptOpenJDK 8 JRE Docker image build and push to Docker Hub'
on:
workflow_dispatch:
push:
tags:
- '*'
pull_request:
branches:
- main
env:
REGISTRY: docker.io
IMAGE_NAME: mablanco/adoptopenjdk8-jre-hotspot
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and Push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Scan image for vulnerabilities
uses: anchore/[email protected]
id: scan
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
fail-build: false
only-fixed: true
- name: Inspect SARIF report
run: cat ${{ steps.scan.outputs.sarif }}
- name: Upload scan SARIF report
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.scan.outputs.sarif }}