Skip to content

.github/workflows/traffic.yaml #112

.github/workflows/traffic.yaml

.github/workflows/traffic.yaml #112

Workflow file for this run

on:
schedule:
# runs once a week on sunday
- cron: "55 23 * * 0"
workflow_dispatch:
permissions: {}
jobs:
traffic:
runs-on: ubuntu-latest
permissions:
id-token: "write"
strategy:
matrix:
repo-values:
- { repo: platform, event: "" }
- { repo: otdfctl, event: otdfctl- }
- { repo: spec, event: spec- }
- { repo: tests, event: tests- }
- { repo: web-sdk, event: web-sdk- }
- { repo: java-sdk, event: java-sdk- }
- { repo: charts, event: charts- }
- { repo: nifi, event: nifi- }
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: "${{ secrets.APP_ID }}"
private-key: "${{ secrets.AUTOMATION_KEY }}"
owner: opentdf
- name: checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- id: get-date
name: Set current date as env variable
run: echo "DATE=$(date +'%Y%m%d')" >>"$GITHUB_OUTPUT"
- name: Get Traffic
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
id: get-traffic
env:
OWNER: opentdf
REPO: ${{ matrix.repo-values.repo }}
EVENT_TYPE: opentdf-${{ matrix.repo-values.event }}github
TODAY_DATE: ${{ steps.get-date.outputs.DATE }}
with:
github-token: ${{ steps.generate_token.outputs.token }}
retries: 3
script: |
var fs = require('fs')
const getMetrics = require('./.github/scripts/metrics.js')
const result = await getMetrics({github})
console.log(result)
const jsonObj = JSON.stringify(result)
await fs.writeFile(process.env.TODAY_DATE + "-" + process.env.EVENT_TYPE +".json", jsonObj, err =>{
if(err) throw err})
return result
#https://github.com/marketplace/actions/authenticate-to-google-cloud#setup
- id: "auth"
name: "Authenticate to Google Cloud"
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY }}
- id: "upload-file"
uses: google-github-actions/upload-cloud-storage@6397bd7208e18d13ba2619ee21b9873edc94427a # v3.0.0
with:
path: "./${{ steps.get-date.outputs.DATE }}-opentdf-${{ matrix.repo-values.event }}github.json"
destination: "prj-opentdf-4fc4-opentdf-github-metrics-bucket-us-38uz"
project_id: "prj-opentdf-4fc4"