This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
forward-v4-workflow.yml
66 lines (57 loc) · 2 KB
/
forward-v4-workflow.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
64
65
66
############################################
# Github Action Workflow to poll and aggregate logs #
############################################
name: POLL/POST Audit Log Data from V4 API
##############################################
# Run once an hour and when pushed to main #
##############################################
on:
push:
branches: main
schedule:
- cron: '59 * * * *'
#################
# Build the job #
#################
jobs:
poll:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
# Clone source code
- name: Checkout source code
uses: actions/checkout@v2
# Install congiure NodeJS
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# Need to install NPM
- name: NPM Install
run: npm install
# If this is the first time we poll, then do a fresh poll. If not, poll from latest cursor.
- name: Poll from Cursor
run: |
if [ -f ".last-cursor-update" ]; then
LAST_CURSOR=$(cat .last-cursor-update)
fi
if [ -z "$LAST_CURSOR" ]; then
echo "FIRST TIME RUNNING AUDIT LOG POLL"
npm start -- --token ${{secrets.AUDIT_LOG_TOKEN}} --org ${{secrets.ORG_NAME}} --file 'audit-log-output.json'
else
echo "RUNNING AUDIT LOG POLL FROM $LAST_CURSOR"
npm start -- --token ${{secrets.AUDIT_LOG_TOKEN}} --org ${{secrets.ORG_NAME}} --cursor $LAST_CURSOR --file 'audit-log-output.json'
fi
curl -X POST -H "Content-Type: application/json" -d @audit-log-output.json ${{secrets.WEBHOOK_URL}}
# Commit the cursor back to source
- name: Commit cursor
uses: EndBug/add-and-commit@v5
with:
author_name: Audit Log Integration
author_email: ${{ secrets.COMMITTER_EMAIL }}
message: "Updating cursor for audit log"
add: ".last-cursor-update --force"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}