Skip to content

Add flags to control service startup #2502

Add flags to control service startup

Add flags to control service startup #2502

name: Test github action with TUF
on:
pull_request:
branches: [ main ]
defaults:
run:
shell: bash
working-directory: ./
concurrency:
group: test-github-action-with-tuf${{ github.head_ref }}
cancel-in-progress: true
jobs:
test-github-action:
name: Test github action with TUF
runs-on: ubuntu-latest
strategy:
fail-fast: false # Keep running if one leg fails.
matrix:
k8s-version:
- v1.31.x
- v1.32.x
- v1.33.x
- v1.34.x
release-version:
- "main" # Test explicitly with latest
go-version:
- 1.25.x
leg:
- test github action with TUF
env:
KO_DOCKER_REPO: registry.local:5000/knative
steps:
- name: Checkout the current action
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Test running the action
uses: ./actions/setup
with:
k8s-version: ${{ matrix.k8s-version }}
version: ${{ matrix.release-version }}
# Install cosign
- name: Install cosign
uses: sigstore/cosign-installer@d7543c93d881b35a8faa02e8e3605f69b7a1ce62 # v3.10.0
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: ${{ matrix.go-version }}
check-latest: true
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
- name: Create sample image
run: |
pushd $(mktemp -d)
go mod init example.com/demo-action-with-tuf
cat <<EOF > main.go
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
EOF
demoimage=$(ko publish -B example.com/demo-action-with-tuf)
echo "demoimage=$demoimage" >> $GITHUB_ENV
echo Created image $demoimage
popd
- name: Initialize cosign with TUF root
run: cosign initialize --mirror ${TUF_MIRROR} --root ./root.json
env:
TUF_MIRROR: ${{ env.TUF_MIRROR }}
- name: Sign with cosign from the action using k8s token
run: |
cosign sign --yes --rekor-url ${REKOR_URL} --fulcio-url ${FULCIO_URL} --allow-insecure-registry ${DEMOIMAGE} --identity-token ${OIDC_TOKEN}
env:
REKOR_URL: ${{ env.REKOR_URL }}
FULCIO_URL: ${{ env.FULCIO_URL }}
DEMOIMAGE: ${{ env.demoimage }}
OIDC_TOKEN: ${{ env.OIDC_TOKEN }}
- name: Verify with cosign from the action using k8s token
run: |
cosign verify --rekor-url "${REKOR_URL}" \
--allow-insecure-registry "${DEMOIMAGE}" \
--certificate-identity "https://kubernetes.io/namespaces/default/serviceaccounts/default" \
--certificate-oidc-issuer "https://kubernetes.default.svc.cluster.local"
env:
REKOR_URL: ${{ env.REKOR_URL }}
DEMOIMAGE: ${{ env.demoimage }}
- name: Checkout TSA for testing.
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: sigstore/timestamp-authority
path: ./src/github.com/sigstore/timestamp-authority
persist-credentials: false
- name: Build timestamp-cli
working-directory: ./src/github.com/sigstore/timestamp-authority
run: |
go build -o ./timestamp-cli ./cmd/timestamp-cli
- name: Exercise TSA
working-directory: ./src/github.com/sigstore/timestamp-authority
run: |
curl ${TSA_URL}/api/v1/timestamp/certchain > ts_chain.pem
echo "myblob" > myblob
if ! ./timestamp-cli --timestamp_server ${TSA_URL} timestamp --hash sha256 --artifact myblob --out response.tsr ; then
echo "failed to timestamp artifact"
exit -1
fi
if ! ./timestamp-cli verify --timestamp response.tsr --artifact "myblob" --certificate-chain ts_chain.pem ; then
echo "failed to verify timestamp"
exit -1
fi
if ! ./timestamp-cli inspect --timestamp response.tsr --format json ; then
echo "failed to inspect the timestamp"
exit -1
fi
env:
TSA_URL: ${{ env.TSA_URL }}
- name: Collect diagnostics
if: ${{ failure() }}
uses: chainguard-dev/actions/kind-diag@3e8a2a226fad9e1ecbf2d359b8a7697554a4ac6d # v1.5.10