-
Notifications
You must be signed in to change notification settings - Fork 115
76 lines (70 loc) · 2.44 KB
/
e2e.detect-workflow-js.schedule.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- 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: |
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=$(echo "${GITHUB_WORKFLOW_REF}" | cut -d '@' -f1 | cut -d '/' -f3-)
if [[ "${WORKFLOW}" != "${workflow}" ]]; then
echo "expected ${workflow}, 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@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
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@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
with:
repository: slsa-framework/example-package
ref: main
- run: ./.github/workflows/scripts/e2e-report-failure.sh