-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (103 loc) · 3.42 KB
/
ci.yaml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: CI
on:
workflow_dispatch:
push:
# Only run when there are changes under proto dir
paths:
- "proto/**"
- ".github/workflows/**"
pull_request:
# Only run when there are changes under proto dir
paths:
- "proto/**"
- ".github/workflows/**"
jobs:
# Run buf's lint to check for errros
buf-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Install buf
run: |
# Installing buf
if [ "${{ env.buf_version }}" == "" ]; then
# Install latest version
sudo ./scripts/buf-installer.sh
else
# Install the defined version
sudo ./scripts/buf-installer.sh --version=${{ env.buf_version}}
fi
- name: Buf lint
uses: bufbuild/buf-lint-action@v1
with:
input: "proto"
# Push the draft branch to buf.build
bsr-push-draft:
runs-on: ubuntu-latest
needs: buf-lint
if: ${{ (github.ref == 'refs/heads/draft') || (github.ref == 'refs/heads/dev') }}
environment: draft
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Install Buf
run: |
# Install Buf
if [ "${{ env.buf_version }}" == "" ]; then
# Install latest version
sudo ./scripts/buf-installer.sh
else
# Install the defined version
sudo ./scripts/buf-installer.sh --version=${{ env.buf_version}}
fi
- name: Update URLs with branch name
run: |
# Add branch name to URLs
find proto -type f -name '*.proto' -print0 | xargs -0 -I {} ./scripts/replace_url.sh {} ${{ github.ref_name }}
- name: Push to buf.build
uses: bufbuild/buf-push-action@v1
with:
input: "proto"
draft: true
buf_token: ${{ secrets.BUF_BSR_TOKEN }}
# Generate and upload protodot diagrams
diagrams:
runs-on: ubuntu-latest
needs: buf-lint
if: ${{ (github.ref == 'refs/heads/draft') || (github.ref == 'refs/heads/dev') }}
steps:
# Setup environment
- name: Checkout the repo
uses: actions/checkout@v4
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
- name: Install librsvg2-bin
run: sudo apt-get install -y librsvg2-bin
# Generate diagrams
- name: Generate Diagrams
run: |
# Install protodot
wget https://github.com/seamia/protodot/raw/master/binaries/protodot-linux-amd64
chmod +x protodot-linux-amd64
mkdir -v -p gen/bin
mv protodot-linux-amd64 gen/bin/protodot
export PATH=${PWD}/gen/bin:${PATH}
# Run generator script
bash scripts/generate_protodot.sh
# Remove .dot files, we do not need them.
find gen/diagrams -type f -name "*.dot" -exec rm -f {} +
# Show generated files
tree gen/diagrams
# Upload diagrams
- name: Cloud Authentication
id: auth
uses: "google-github-actions/auth@v1"
with:
credentials_json: "${{ secrets.GOOGLE_CREDENTIALS }}"
- name: Setup Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Upload Diagrams
run: |
# '-J' options is to set Content-Encoding to gzip
gsutil -m rsync -J -R -d gen/diagrams gs://docs-cmp-files/diagrams/${{ github.ref_name }}