-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (75 loc) · 3.1 KB
/
ci-scripts.yml
File metadata and controls
84 lines (75 loc) · 3.1 KB
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
77
78
79
80
81
82
83
84
name: CI-Scripts
on:
workflow_dispatch:
inputs:
build-dependent:
description: 'Should build dependent repositories?'
required: false
default: false
type: boolean
push:
branches:
- 'master'
schedule:
- cron: "42 23 31 12 *"
jobs:
create-dependent-matrix:
runs-on: ubuntu-latest
name: 'Find dependent repositories'
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
has_dependents: ${{ steps.set-matrix.outputs.has_dependents }}
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
- name: Create dependent build matrix (or empty)
id: set-matrix
shell: bash
run: |
BUILD_DEPENDENT="${{ inputs.build-dependent || github.event.inputs.build-dependent || 'false' }}"
EVENT="${{ github.event_name }}"
if [[ "$EVENT" != "push" && "$EVENT" != "schedule" && "$EVENT" != "workflow_dispatch" && "$EVENT" != "workflow_call" ]]; then
echo "Dependent builds: disabled: unsupported event=$EVENT"
echo "has_dependents=false" >> "$GITHUB_OUTPUT"
echo 'matrix={"include":[]}' >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ ( "$EVENT" == "workflow_dispatch" || "$EVENT" == "workflow_call" ) && "$BUILD_DEPENDENT" != "true" ]]; then
echo "Dependent builds: disabled: build-dependent input is false"
echo "has_dependents=false" >> "$GITHUB_OUTPUT"
echo 'matrix={"include":[]}' >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ ! -f ./.github/dependent-repositories.txt ]]; then
echo "Dependent builds: disabled: dependent-repositories.txt not found"
echo "has_dependents=false" >> "$GITHUB_OUTPUT"
echo 'matrix={"include":[]}' >> "$GITHUB_OUTPUT"
exit 0
fi
count="$(jq -e '.include | if type=="array" then length else error(".include must be an array") end' ./.github/dependent-repositories.txt)"
if [[ "$count" == "0" ]]; then
echo "Dependent builds: disabled: dependent-repositories.txt empty"
echo "has_dependents=false" >> "$GITHUB_OUTPUT"
echo 'matrix={"include":[]}' >> "$GITHUB_OUTPUT"
exit 0
fi
matrix="$(jq -c '.' ./.github/dependent-repositories.txt)"
echo "Dependent builds: enabled"
echo "has_dependents=true" >> "$GITHUB_OUTPUT"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
build-dependent:
needs: [create-dependent-matrix]
runs-on: ubuntu-latest
name: 'Build dependent'
if: ${{ needs.create-dependent-matrix.outputs.has_dependents == 'true' }}
strategy:
matrix: ${{fromJson(needs.create-dependent-matrix.outputs.matrix)}}
steps:
- name: Start ${{ matrix.repository }} build
uses: benc-uk/workflow-dispatch@v1.2.4
with:
workflow: Nightly
repo: ${{ matrix.repository }}
ref: ${{ matrix.branch }}
token: ${{ secrets.WORKFLOW_ACCESS_TOKEN }}
inputs: '{ "build-dependent": "${{ matrix.build-dependent }}" }'