Skip to content

Merge pull request #7 from e7d/feat/main/improve-github-actions #74

Merge pull request #7 from e7d/feat/main/improve-github-actions

Merge pull request #7 from e7d/feat/main/improve-github-actions #74

Workflow file for this run

name: docker-image
on:
push:
tags:
- "*"
branches:
- "main"
pull_request:
branches:
- "main"
permissions:
contents: read
packages: write
pull-requests: write
env:
PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
name=${{ vars.GHCR_IMAGE }}
name=${{ vars.DOCKERHUB_IMAGE }},enable=${{ github.event_name != 'pull_request' }}
labels: |
org.opencontainers.image.title=docker-diskmark
org.opencontainers.image.description=A disk benchmarking tool for Docker
org.opencontainers.image.revision=${{ env.SHA }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=edge,branch=$repo.default_branch
type=ref,event=pr
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ env.PLATFORMS }}
cache-from: type=gha
cache-to: type=gha
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Docker Scout
id: docker-scout
if: ${{ github.event_name == 'pull_request' }}
uses: docker/scout-action@v1
with:
command: cves,recommendations,compare
image: ${{ steps.meta.outputs.tags }}
to: ${{ vars.GHCR_IMAGE }}:latest
ignore-base: true
ignore-unchanged: true
only-fixed: true
# only-severities: critical,high
write-comment: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Update repo description
if: ${{ github.ref == 'refs/heads/main' }}
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ vars.DOCKERHUB_IMAGE }}