Skip to content

schedule create-container_based-predicate #573

schedule create-container_based-predicate

schedule create-container_based-predicate #573

# Copyright 2023 SLSA Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: schedule create-container_based-predicate
# This workflow requires `id-token: write` permissions to determine the
# builder identity.
on:
# Daily run.
schedule:
- cron: "0 4 * * *"
workflow_dispatch:
permissions: read-all
env:
GH_TOKEN: ${{ github.token }}
ISSUE_REPOSITORY: ${{ github.repository }}
jobs:
predicate:
outputs:
repository: ${{ steps.detect.outputs.repository }}
ref: ${{ steps.detect.outputs.ref }}
workflow: ${{ steps.detect.outputs.workflow }}
runs-on: ubuntu-latest
permissions:
id-token: write # Needed to detect the current reusable repository and ref.
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Detect the builder ref
id: detect
uses: slsa-framework/slsa-github-generator/.github/actions/detect-workflow-js@main
- name: Update the build definition
# We use a build definition hard-coded in testadata. To ensure validation against
# workflow context, we must update the source references.
run: |
bdTemplate="internal/builders/docker/testdata/build-definition.json"
jq -r --arg GITHUB_SHA "$GITHUB_SHA" '.externalParameters.source.digest.sha1 = $GITHUB_SHA | .resolvedDependencies[0].digest.sha1 = $GITHUB_SHA' "${bdTemplate}" > build-definition.json
- name: Create predicate
id: predicate
uses: ./.github/actions/create-container_based-predicate
with:
build-definition: "build-definition.json"
binary-sha256: "46b3ce0fbb2998880c5518225b41ddf49fc0850b9b9a25e1ac944bc587c03ea7"
binary-uri: "git+https://github.com/${{ steps.detect.outputs.repository }}@${{ steps.detect.outputs.ref }}"
builder-id: "https://github.com/${{ steps.detect.outputs.repository }}/${{ steps.detect.outputs.workflow }}@${{ steps.detect.outputs.ref }}"
output-file: "predicate.json"
- run: ./.github/workflows/scripts/schedule.actions/verify-container_based-predicate.sh
env:
PREDICATE: predicate.json
if-succeed:
needs: [predicate]
runs-on: ubuntu-latest
# We use `== 'failure'` instead of ` != 'success'` because we want to ignore skipped jobs, if there are any.
if: github.event_name != 'workflow_dispatch' && needs.predicate.result != 'failure'
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: slsa-framework/example-package
ref: main
- run: ./.github/workflows/scripts/e2e-report-success.sh
if-failed:
needs: [predicate]
runs-on: ubuntu-latest
if: always() && github.event_name != 'workflow_dispatch' && needs.predicate.result == 'failure'
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: slsa-framework/example-package
ref: main
- run: ./.github/workflows/scripts/e2e-report-failure.sh