Skip to content

Merge pull request #308 from Permify/dependabot/npm_and_yarn/bufbuild… #154

Merge pull request #308 from Permify/dependabot/npm_and_yarn/bufbuild…

Merge pull request #308 from Permify/dependabot/npm_and_yarn/bufbuild… #154

Workflow file for this run

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