Skip to content

Update build base image to -sfw #169

Update build base image to -sfw

Update build base image to -sfw #169

name: run-tests-on-pr
permissions:
contents: read
on:
pull_request:
jobs:
test-multi-arch-build:
uses: docker/github-builder/.github/workflows/build.yml@a492c6d04fd3315f67230809b44d60cc0acd50b3 # main
if: ${{ !github.event.pull_request.head.repo.fork }}
permissions:
id-token: write # required to request the GitHub OIDC token
with:
output: image
push: false
platforms: linux/amd64,linux/arm64
sbom: true
cache: true
context: .
set-meta-labels: true
set-meta-annotations: true
meta-images: |
hello-world
meta-tags: |
type=ref,event=pr
registry-identities: |
- type: dockerhub
registry: docker.io
username: ${{ vars.DOCKER_HUB_ORG }}
connection_id: ${{ vars.DOCKER_HUB_OIDC_CONNECTION_ID }}
scan-container:
runs-on: ubuntu-latest
permissions:
pull-requests: write
id-token: write # required to request the GitHub OIDC token
if: ${{ !github.event.pull_request.head.repo.fork }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit
- name: checkout code in current PR branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Set up Docker
uses: docker/setup-docker-action@77e84dbf09b47d1e29270283c22f16145aa85ca1 # v5.4.0
with:
daemon-config: |
{
"debug": true,
"features": {
"containerd-snapshotter": true
}
}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
with:
version: latest
- name: docker login
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
env:
DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKER_HUB_OIDC_CONNECTION_ID }}
with:
registry-auth: |
- registry: docker.io
username: ${{ vars.DOCKER_HUB_ORG }}
- registry: dhi.io
username: ${{ vars.DOCKER_HUB_ORG }}
- name: Build container image from PR branch
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: mode=max
sbom: true
tags: hello-world:pr-${{ github.event.number }}
- name: docker images
run: |
docker images
- name: checkout code in main branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: main
- name: Build container image from main branch
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: mode=max
sbom: true
tags: hello-world:main
- name: docker images
run: |
docker images
- name: Docker Scout Comparison between main branch and current PR branch
uses: docker/scout-action@7c6b6c3f7844478ace1ffd4e7aef649053d1f87d # v1.24.0
with:
command: compare
image: local://hello-world:pr-${{ github.event.number }}
to: local://hello-world:main
write-comment: true
github-token: ${{ secrets.GITHUB_TOKEN }}
organization: ${{ vars.DOCKER_HUB_ORG }}
test-container:
runs-on: ubuntu-latest
permissions:
id-token: write # required to request the GitHub OIDC token
steps:
- name: Harden Runner
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit
- name: checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
with:
version: latest
- name: docker login
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
env:
DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKER_HUB_OIDC_CONNECTION_ID }}
with:
registry-auth: |
- registry: docker.io
username: ${{ vars.DOCKER_HUB_ORG }}
- name: install score-compose
uses: score-spec/setup-score@888a7deafd396c3f3f05e00d2d9b0ab225799ac0 # v3.2.4
with:
file: score-compose
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
- name: make compose-test
run: |
make compose-test
- name: make kind-create-cluster
run: |
make kind-create-cluster
- name: make kind-load-image
run: |
make kind-load-image
- name: install score-k8s
uses: score-spec/setup-score@888a7deafd396c3f3f05e00d2d9b0ab225799ac0 # v3.2.4
with:
file: score-k8s
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
- name: make k8s-up
id: k8s-up
run: |
make k8s-up
- name: catch k8s-up errors
if: ${{ failure() && steps.k8s-up.outcome == 'failure' }}
run: |
kubectl get events
kubectl logs \
-l score-workload=hello-world