-
Notifications
You must be signed in to change notification settings - Fork 9
58 lines (51 loc) · 1.7 KB
/
trigger_partner_wf.yaml
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
name: Trigger partner workflows
on:
workflow_call:
inputs:
pending_matrices:
description: json string of gh matrix (to be used with fromJson())
type: string
required: true
secrets:
PAT:
required: true
jobs:
trigger_partners:
environment: production
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(inputs.pending_matrices) }}
# inputs.pending_matrices looks like:
# include:
# - partner_id: ilastik
# pending_matrix: "... json gh style matrix"
# - ...
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
- name: trigger ${{ matrix.partner_id }}
shell: python
run: |
import json
import os
from pathlib import Path
import requests
# load partner config
partner_details_path = Path("partner_details.json")
with partner_details_path.open() as f:
partner_details = json.load(f)
for config in partner_details:
if config["id"] == "${{ matrix.partner_id }}":
config = config["test_summaries"]
break
else:
raise RuntimeError(f"Missing partner '${{ matrix.partner_id }}' in {partner_details_path}")
r = requests.post(
f"${{ github.api_url }}/repos/{ config['repository'] }/actions/workflows/"
f"{ config['workflow'] }/dispatches",
headers=dict(Accept="application/vnd.github.v3+json", Authorization="token ${{ secrets.PAT }}"),
json=dict(ref=config["workflow_ref"], inputs=dict(pending_matrix='${{ matrix.pending_matrix }}')),
)
r.raise_for_status()