-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (59 loc) · 1.93 KB
/
trigger-update-dependencies.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
name: Trigger dependencies update
on:
workflow_call:
secrets:
TOKEN:
description: Token to use to trigger update dependencies
required: true
jobs:
# Automatically gets root repos targets
targets:
name: Get targets
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.targets.outputs.result }}
steps:
- uses: actions/github-script@v6
id: targets
env:
TOKEN: ${{ secrets.TOKEN }}
with:
github-token: ${{ secrets.TOKEN }}
script: |
async function getRepoPackages(repo) {
const response = await fetch(
`https://raw.githubusercontent.com/Humanoidfr/${repo}/main/composer.json`,
{
headers: {
Authorization: `token ${process.env.TOKEN}`,
},
}
);
const composerJson = await response.json();
return Object.keys(composerJson.require)
.filter((package) => package.startsWith("humanoid"))
.map((package) => package.split("/")[1]);
}
async function getTargets() {
const targets = [];
const rootRepos = ["frandroid", "madmoizelle", "numerama"];
for (const repo of rootRepos) {
const packages = await getRepoPackages(repo);
if (packages.includes(context.repo.repo)) {
targets.push(repo);
}
}
return targets;
}
return await getTargets();
trigger-update:
name: Trigger dependencies update
runs-on: ubuntu-latest
needs: targets
strategy:
matrix:
target: ${{ fromJson(needs.targets.outputs.targets) }}
steps:
- run: gh workflow run composer-update.yml --repo Humanoidfr/${{ matrix.target }}
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}