-
Notifications
You must be signed in to change notification settings - Fork 13
50 lines (43 loc) · 1.52 KB
/
release-metrics.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
name: Send publish metrics to bigquery
on:
release:
types: published
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_BQ_METRICS_KEY }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
create_credentials_file: true
export_environment_variables: true
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Print event info for debug
run: cat $GITHUB_EVENT_PATH
- name: Check for release key
run: echo "HAS_RELEASE_KEY=$(jq 'has("release")' $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
- name: Write release json
if: ${{env.HAS_RELEASE_KEY== 'true'}}
run: 'jq -c ''.release |
{
package_name: .name | split(" ")[0],
name,
tag_name,
version: try(.tag_name | split("-v")[1]),
html_url,
target_commitish,
created_at,
published_at,
draft,
prerelease
}'' $GITHUB_EVENT_PATH > releases.json'
- name: Debug release json
if: ${{env.HAS_RELEASE_KEY== 'true'}}
run: cat releases.json
# Avoid rate limit exceeded error in bq load step
- name: Sleep for random time
run: sleep $((RANDOM % 120))
- run: bq load --source_format=NEWLINE_DELIMITED_JSON metrics.releases releases.json