Skip to content

schedule detect-workflow-js #664

schedule detect-workflow-js

schedule detect-workflow-js #664

# 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 detect-workflow-js
on:
# Daily run.
schedule:
- cron: "0 4 * * *"
workflow_dispatch:
permissions: read-all
env:
GH_TOKEN: ${{ github.token }}
ISSUE_REPOSITORY: ${{ github.repository }}
jobs:
detect-workflow:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: detect
uses: ./.github/actions/detect-workflow-js
- id: verify
env:
REPO: ${{ steps.detect.outputs.repository }}
REF: ${{ steps.detect.outputs.ref }}
WORKFLOW: ${{ steps.detect.outputs.workflow }}
run: |
set -euo pipefail
if [[ "${REPO}" != "${GITHUB_REPOSITORY}" ]]; then
echo "expected ${GITHUB_REPOSITORY}, got ${REPO}"
exit 1
fi
# When calling this action from a caller workflow, this will be
# the caller github ref.
if [[ "${REF}" != "${GITHUB_REF}" ]]; then
echo "expected ${GITHUB_REF}, got ${REF}"
exit 1
fi
# When calling this action from a caller workflow, this will be
# the caller workflow.
workflow_name=$(echo "${GITHUB_WORKFLOW_REF}" | cut -d '@' -f1 | cut -d '/' -f3-)
if [[ "${WORKFLOW}" != "${workflow_name}" ]]; then
echo "expected ${workflow_name}, got ${WORKFLOW}"
exit 1
fi
if-succeed:
needs: [detect-workflow]
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.detect-workflow.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: [detect-workflow]
runs-on: ubuntu-latest
if: always() && github.event_name != 'workflow_dispatch' && needs.detect-workflow.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