Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

upgrade syft

upgrade syft #139

name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: ["main"]
# Publish semver tags as releases.
tags: ["v*.*.*"]
pull_request_target:
branches: ["main"]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: docker/docker-index
SHA: ${{ github.event.pull_request.head.sha || github.event.after }}
DOCKERFILE_PATH: Dockerfile
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ env.SHA }}
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.revision=${{ env.SHA }}
com.docker.image.source.entrypoint=${{ env.DOCKERFILE_PATH }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image on Push
if: ${{ github.event_name == 'push' }}
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
platforms: "linux/amd64,linux/arm64"
context: .
file: ${{ env.DOCKERFILE_PATH }}
push: true
load: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build Docker image on PR
if: ${{ github.event_name == 'pull_request_target' }}
id: build-pr
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
file: ${{ env.DOCKERFILE_PATH }}
push: false
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Extract SBOMs for images that are not getting pushed to the registry
- name: Extract and upload SBOM
if: ${{ github.event_name == 'pull_request_target' }}
id: sbom
uses: atomist-skills/index-image-action@main
with:
image: ${{ steps.meta.outputs.tags }}
api-key: ${{ secrets.ATOMIST_API_KEY }}
workspace: ${{ secrets.ATOMIST_WORKSPACE }}