-
-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (42 loc) · 1.5 KB
/
Copy pathreport.yml
File metadata and controls
42 lines (42 loc) · 1.5 KB
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
name: Docs report
on:
schedule:
- cron: "0 6 * * *" # daily at 06:00 UTC
workflow_dispatch:
permissions:
contents: read
id-token: write
concurrency:
group: docs-report
cancel-in-progress: false
jobs:
report:
runs-on: ubuntu-latest
steps:
- name: Install GoAccess
run: sudo apt-get update && sudo apt-get install -y goaccess
- name: Configure AWS credentials (OIDC)
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE_ARN }}
aws-region: eu-west-1
- name: Sync CloudFront logs
run: |
mkdir -p cflogs
aws s3 sync "s3://${{ secrets.DOCS_LOGS_BUCKET }}/cf/" cflogs/ --only-show-errors
- name: Generate GoAccess report
run: |
if ls cflogs/*.gz >/dev/null 2>&1; then
gzip -dc cflogs/*.gz | goaccess - \
--log-format=CLOUDFRONT \
--html-report-title="access stats" \
-o report.html
else
echo "<!doctype html><meta charset=utf-8><title>No data</title><h1>No access logs yet</h1>" > report.html
fi
- name: Publish to /report/ and invalidate
run: |
aws s3 cp report.html "s3://${{ secrets.DOCS_S3_BUCKET }}/report/index.html" \
--content-type "text/html; charset=utf-8" --cache-control "no-cache"
aws cloudfront create-invalidation \
--distribution-id "${{ secrets.DOCS_CF_DISTRIBUTION_ID }}" --paths "/report/*"