ci: Add GitHub Actions workflow for GCE deployment

This commit adds a new GitHub Actions workflow file that builds the
Go backend binary and deploys it to a Google Compute Engine (GCE)
instance. It leverages Google Cloud Workload Identity Federation for
authentication and uses `gcloud compute scp` to copy the binary into
the target user's `~/.local/bin` directory, finally restarting the
`picoclaw` service via SSH.

Co-authored-by: TanLuong <28281768+TanLuong@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-03-25 23:02:58 +00:00
parent bc1d2dc456
commit e41b2722d6

66
.github/workflows/deploy-gce.yml vendored Normal file
View file

@ -0,0 +1,66 @@
name: Build and Deploy to GCE
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write' # Required for Workload Identity Federation
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libolm-dev
- name: Build Go backend
run: make build
- name: Determine binary name
id: binary
run: |
# The Makefile outputs a binary named picoclaw-linux-amd64
echo "path=build/picoclaw-linux-amd64" >> $GITHUB_OUTPUT
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: '${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}'
service_account: '${{ secrets.GCP_SERVICE_ACCOUNT }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
- name: 'Deploy binary to GCE'
run: |
# Ensure ~/.local/bin exists
gcloud compute ssh ${{ secrets.GCE_INSTANCE }} \
--zone=${{ secrets.GCE_ZONE }} \
--project=${{ secrets.GCP_PROJECT_ID }} \
--command="mkdir -p ~/.local/bin"
# Copy the binary to the instance
gcloud compute scp ${{ steps.binary.outputs.path }} ${{ secrets.GCE_INSTANCE }}:~/.local/bin/picoclaw \
--zone=${{ secrets.GCE_ZONE }} \
--project=${{ secrets.GCP_PROJECT_ID }}
# Make it executable and restart the service
gcloud compute ssh ${{ secrets.GCE_INSTANCE }} \
--zone=${{ secrets.GCE_ZONE }} \
--project=${{ secrets.GCP_PROJECT_ID }} \
--command="chmod +x ~/.local/bin/picoclaw && sudo systemctl restart picoclaw"