forked from github/ghec-audit-log-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode-workflow.yml
40 lines (38 loc) · 1.42 KB
/
node-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
name: Poll Audit Log
# Run it every 30 minutes
on:
schedule:
- cron: "*/30 * * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: '12'
# Get the latest cursor file from the repo
- run: export LAST_CURSOR=$(cat .last-cursor-update)
# Run the script with the latest cursor if present in the repo
- run: npm install
- run: |
if [ -z "$LAST_CURSOR" ]; then
echo "FIRST TIME RUNNING AUDIT LOG POLL"
npm start -- --pretty --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 -- --pretty --token ${{secrets.AUDIT_LOG_TOKEN}} --org ${{secrets.ORG_NAME}} --file 'audit-log-output.json'
fi
# Cat the output. Optionally send it somewhere else
- run: cat audit-log-output.json
# Commit the .last-cursor-update so we can reuse it in the upcoming workflows
- name: Commit cursor
uses: EndBug/add-and-commit@v5
with:
author_name: Audit Log Integration
author_email: integration@yourcompany.com
message: "Updating audit log cursor"
add: ".last-cursor-update"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}