Skip to content

Merge pull request #1779 from moonlight16/feature/tekton-shipwright-v… #9

Merge pull request #1779 from moonlight16/feature/tekton-shipwright-v…

Merge pull request #1779 from moonlight16/feature/tekton-shipwright-v… #9

name: Build HyperShift CI Image
on:
push:
branches: [main]
paths:
- '.github/dockerfiles/hypershift-ci/**'
- '.github/workflows/build-hypershift-ci-image.yaml'
pull_request:
paths:
- '.github/dockerfiles/hypershift-ci/**'
- '.github/workflows/build-hypershift-ci-image.yaml'
workflow_dispatch:
# Explicit permissions - jobs request only what they need
permissions: {}
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/hypershift-ci
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .github/dockerfiles/hypershift-ci
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run Trivy vulnerability scanner
if: github.event_name != 'pull_request'
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
# Never fail - results are uploaded to GitHub Security tab (code-scanning)
exit-code: '0'
- name: Upload Trivy scan results
if: github.event_name != 'pull_request' && !cancelled()
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
with:
sarif_file: 'trivy-results.sarif'