-
Notifications
You must be signed in to change notification settings - Fork 14
96 lines (78 loc) · 2.72 KB
/
protos.yml
File metadata and controls
96 lines (78 loc) · 2.72 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
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
name: Overwrite Proto Directory
on:
push:
branches: [ "main" ]
permissions:
contents: read
jobs:
copy-proto:
permissions:
contents: write # for Git to git push
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
with:
egress-policy: audit
- name: Checkout Repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Run Bash Script to Overwrite Proto Directory
run: |
#!/bin/bash
REPO_URL="https://github.com/Permify/permify.git"
TEMP_DIR="temp_dir"
TARGET_DIR="proto"
# Clone the repository to a temporary directory
git clone --depth=1 $REPO_URL $TEMP_DIR
# Check if the clone was successful
if [ $? -ne 0 ]; then
echo "Failed to clone repository."
exit 1
fi
# Remove the existing proto directory if it exists
if [ -d "$TARGET_DIR" ]; then
rm -rf $TARGET_DIR
fi
# Create the target directory and copy the specific directory to the desired location
mkdir -p $TARGET_DIR
cp -r $TEMP_DIR/proto/* $TARGET_DIR
# Check if the copy was successful
if [ $? -ne 0 ]; then
echo "Failed to copy the directory."
# Clean up the temporary repository directory
rm -rf $TEMP_DIR
exit 1
fi
# Clean up the temporary repository directory
rm -rf $TEMP_DIR
echo "Successfully copied the proto directory to $TARGET_DIR."
- name: Install Node.js and Dependencies
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: '18'
- name: Install Buf
run: |
# Download and install buf
wget https://github.com/bufbuild/buf/releases/download/v1.7.0/buf-Linux-x86_64 -O /usr/local/bin/buf
chmod +x /usr/local/bin/buf
buf --version
- name: Generate Code with Buf
run: |
# Navigate to the proto directory and run buf generate
npm install ts-proto
buf generate
- name: Add and Commit Changes
run: |
git config --global user.name 'GitHub Actions Bot'
git config --global user.email '<>'
git add src/grpc/generated package-lock.json package.json proto/
if git diff-index --quiet HEAD; then
echo "No changes to commit"
else
git commit -m "Update generated sdk directory with latest changes"
fi
- name: Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin main