forked from SEKOIA-IO/intake-formats
-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (56 loc) · 2.26 KB
/
build-intakes.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
name: Build Intakes
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
workflow_dispatch:
jobs:
find-intakes:
name: Find intakes in repo
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.list-intakes.outputs.matrix }}
steps:
- name: Check-out the repo under $GITHUB_WORKSPACE
uses: actions/checkout@v3
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- id: list-intakes
name: List intakes having changed files
run: |
if ${{ github.event_name == 'workflow_dispatch' }}; then
echo "matrix=$(find . -maxdepth 2 -type d ! -name '.*' ! -path './.git*' ! -path './utils*' ! -name '_meta' | awk -F/ 'NF == 3 && $2 {print $2 "/" $3}' | sort | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
exit 0
fi
if ${{ github.event_name == 'pull_request' }}; then
start="HEAD^1"
end="HEAD"
else
start=${{ github.event.before }}
end=${{ github.event.after }}
fi
echo "matrix=$(comm -12 <(cut -d "/" -f 1,2 <<< "$(git diff --name-only -r $start $end | sort | uniq)") <(find . -maxdepth 2 -type d ! -name '.*' ! -path './.git*' ! -path './utils*' ! -name '_meta' | awk -F/ 'NF == 3 && $2 {print $2 "/" $3}' | sort | uniq) | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
deploy-intakes:
name: Deploy intakes
runs-on: ubuntu-latest
needs: find-intakes
if: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && needs.find-intakes.outputs.matrix != '[]' }}
strategy:
matrix:
intake: ${{fromJSON(needs.find-intakes.outputs.matrix)}}
steps:
- name: my-app-install token
id: my-app
uses: getsentry/action-github-app-token@v1
with:
app_id: ${{ secrets.PRIVATE_DISPATCH_APP_ID }}
private_key: ${{ secrets.PRIVATE_DISPATCH_APP_SECRET_KEY }}
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ steps.my-app.outputs.token }}
event-type: publish-intakes
repository: SekoiaLab/platform
client-payload: '{"intake": "${{ matrix.intake }}"}'