Skip to content

Merge pull request #1148 from SEKOIA-IO/feat/zscaler-zia-user-name #3

Merge pull request #1148 from SEKOIA-IO/feat/zscaler-zia-user-name

Merge pull request #1148 from SEKOIA-IO/feat/zscaler-zia-user-name #3

Workflow file for this run

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 }}"}'