I ended up using appleboy for this with a great deal of success:

https://github.com/appleboy/ssh-action

Answer from Nicole Staline on Stack Overflow
🌐
Google Cloud
cloud.google.com › blog › products › devops-sre › using-github-actions-with-google-cloud-deploy
Using GitHub Actions with Google Cloud Deploy | Google Cloud Blog
May 9, 2023 - You can find the Cloud Deploy GitHub Action with documentation here, and a complete standalone example here. Tutorials for various Cloud Deploy features are here.
🌐
GitHub
github.com › bitovi › github-actions-deploy-docker-to-gcp
GitHub - bitovi/github-actions-deploy-docker-to-gcp: Deploy an app or service to GCP Compute Engine
The GCP IAM instance profile to use for the GCP VM instance. Default is ${GITHUB_ORG_NAME}-${GITHUB_REPO_NAME}-${GITHUB_BRANCH_NAME} ... The GCP IAM instance type to use. Default is t2.small. See [this list](TODO: UPDATE) for reference ... Set to true to destroy the stack. Default is "" - Will delete the elb_logs bucket after the destroy action runs. ... Set to override the GCP resource identifier for the deployment.
Author   bitovi
🌐
Medium
medium.com › @vngauv › from-github-to-gce-automate-deployment-with-github-actions-27e89ba6add8
Google Compute Engine CI/CD with GitHub Actions | by Virak Ngauv | Medium
January 26, 2022 - Basically continuous deployment. In its final state, it should really only update when my main branch is updated but for now it updates with any new commit. Thousand Foot View aka Thousand Foot Run-On Sentence · First, a GitHub Action waits for a git-push event to kick-off a workflow that follows an instructional YAML file running on a GitHub-hosted VM to build an image that follows a Dockerfile and deploy the image to Google Compute Engine to run a container that executes a command to run your Node.js application.
🌐
DEV Community
dev.to › ivanchiou › cicd-pipeline-using-github-actions-to-deploy-to-google-cloud-platform-gcp-3105
CI/CD pipeline using GitHub Actions to deploy to Google Cloud Platform (GCP) - DEV Community
April 30, 2025 - Add Secrets to GitHub: Navigate to Settings → Secrets and Variables → Actions, and add: GCP_SSH_PRIVATE_KEY: Your private SSH key (no passphrase). GCP_VM_IP: Your VM’s external IP.
🌐
Medium
medium.com › @jayarch › deploying-a-ci-cd-pipeline-to-gcp-using-github-actions-c5dd39074a7f
Deploying a CI/CD pipeline to GCP using Github Actions | by j.xcvii | Medium
July 13, 2025 - # # # - Artifact Registry Administrator ... in the "env" block to match your values. name: 'Build and Deploy to Cloud Run' on: push: branches: - "main" env: PROJECT_ID: 'my-project' # TODO: update to your Google Cloud project ID ...
🌐
Medium
medium.com › @rasmus-haapaniemi › how-to-use-github-actions-to-deploy-your-docker-image-to-google-cloud-96515edfb689
How to use GitHub Actions to deploy your Docker image to Google Cloud | by Rasmus Haapaniemi | Medium
January 7, 2025 - Here are the steps to securely handle the service account key: Create the service account key in Google Cloud and download the JSON file. Add the JSON file as a secret in your GitHub repository (e.g., GCP_DEPLOY_SA).
🌐
GitHub
github.com › marketplace › actions › create-google-compute-engine-vm
Create Google Compute Engine VM · Actions · GitHub Marketplace · GitHub
jobs: job_id: permissions: contents: "read" id-token: "write" steps: # ... - uses: "google-github-actions/auth@v1" with: workload_identity_provider: "projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider" service_account: "my-service-account@my-project.iam.gserviceaccount.com" - uses: "aplr/action-gcloud-compute-instance@v0.0.5" with: name_prefix: "my-instance" source_instance_template: "my-template" If you are hosting your own runners, and those runners are on Google Cloud, you can leverage the Application Default Credentials of the instance. This will authenticate requests as the service account attached to the instance. This only works using a custom runner hosted on GCP.
Find elsewhere
🌐
GitHub
github.com › marketplace › actions › google-cloud-compute-engine-deploy
Google Cloud Compute Engine Deploy · Actions · GitHub Marketplace · GitHub
Create a base instance template to be cloned by this action. Create a managed instance group. Please note that currently only regional instance groups are supported. Create Service Account with Roles Compute Admin and Service Account User and export a new JSON key. By default this action expects a deploy.yml in the root directory of the repository. Here is an example:
🌐
GitHub
github.com › google-github-actions › deploy-cloudrun
GitHub - google-github-actions/deploy-cloudrun: A GitHub Action for deploying services to Google Cloud Run. · GitHub
jobs: job_id: permissions: contents: 'read' id-token: 'write' steps: # ... - uses: 'google-github-actions/auth@v3' with: workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider' service_account: 'my-service-account@my-project.iam.gserviceaccount.com' - uses: 'google-github-actions/deploy-cloudrun@v3' with: image: 'us-docker.pkg.dev/cloudrun/container/hello:latest' service: 'hello-cloud-run' If you are hosting your own runners, and those runners are on Google Cloud, you can leverage the Application Default Credentials of the instance. This will authenticate requests as the service account attached to the instance. This only works using a custom runner hosted on GCP.
Starred by 584 users
Forked by 135 users
Languages   TypeScript 95.4% | JavaScript 2.8% | Dockerfile 1.8%
🌐
Google Cloud
cloud.google.com › blog › products › devops-sre › deploy-to-cloud-run-with-github-actions
Deploy to Cloud Run with GitHub Actions | Google Cloud Blog
September 28, 2023 - You have now deployed a Cloud Run instance using GitHub Actions! You can find the Cloud Run GitHub Action with documentation here, and other GitHub Actions examples here.
🌐
Stack Overflow
stackoverflow.com › questions › 79122874 › continuous-deployment-from-github-action-to-google-cloud-vm-using-docker
Continuous deployment from GitHub Action to Google Cloud VM using Docker - Stack Overflow
docker push your-dockerhub-username/your-app-name:latest deploy: runs-on: ubuntu-latest needs: build steps: - name: Install SSH client run: sudo apt-get install -y openssh-client - name: Add SSH key uses: shimataro/ssh-key-action@v2 with: key: ${{ secrets.SSH_PRIVATE_KEY }} known_hosts: ${{ secrets.GCP_VM_IP }} - name: Deploy to Google Cloud VM run: | ssh -o StrictHostKeyChecking=no username@${{ secrets.GCP_VM_IP }} << 'EOF' docker pull your-dockerhub-username/your-app-name:latest docker stop your-container-name || true docker rm your-container-name || true docker run -d --name your-container-name -p 3000:3000 your-dockerhub-username/your-app-name:latest EOF · This will connect to your VM and pull-down latest code from your repo. Now every time code is pushed on main branch, Github Actions will automatically deploy latest version of your code to VM.
🌐
Towards Data Science
towardsdatascience.com › home › latest › deploy to google cloud run using github actions
Deploy To Google Cloud Run Using Github Actions | Towards Data Science
March 5, 2025 - I stumbled a lot when it came to configuring the roles and permissions due to GCP’s unpredictable behavior behind their roles, but thankfully wrote down every step that I went through to get a workable solution so that you don’t need to do spend the hours of trial an error to accomplish an integration between Github Actions and Google Cloud Run. The example I will be stepping you through will be a simple Flask server deployed via Github Actions to Google Cloud Run.
🌐
Towards Data Science
towardsdatascience.com › home › latest › seamless ci/cd pipelines with github actions on gcp: your tools for effective mlops
Seamless CI/CD Pipelines with GitHub Actions on GCP: Your Tools for Effective MLOps | Towards Data Science
March 5, 2025 - ... Copy the output from the terminal and create the _GCP_SSH_PRIVATEKEY variable. Now make any change to the code, push it to the main branch, and the GitHub Actions files should trigger automatically.
🌐
Alexander Hose
alexanderhose.com › how-to-integrate-github-actions-with-google-cloud-platform
How to Integrate GitHub Actions with Google Cloud Platform
April 11, 2025 - Here's the complete GitHub Actions workflow configuration: name: Deploy code to GCP on: push: branches: [ "main" ] pull_request: branches: [ "main" ] workflow_dispatch: jobs: build: runs-on: ubuntu-latest permissions: id-token: write contents: ...
🌐
GitHub
github.com › google-github-actions › create-cloud-deploy-release
GitHub - google-github-actions/create-cloud-deploy-release: A GitHub Action for creating releases via Cloud Deploy. · GitHub
jobs: job_id: permissions: contents: 'read' id-token: 'write' steps: # ... - uses: 'google-github-actions/auth@v3' with: workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider' service_account: 'my-service-account@my-project.iam.gserviceaccount.com' - uses: 'google-github-actions/create-cloud-deploy-release@v2' with: name: 'example-app' ... If you are hosting your own runners, and those runners are on Google Cloud, you can leverage the Application Default Credentials of the instance. This will authenticate requests as the service account attached to the instance. This only works using a custom runner hosted on GCP.
Starred by 24 users
Forked by 7 users
Languages   TypeScript 98.3% | JavaScript 1.7%
🌐
Reddit
reddit.com › r/googlecloud › ssh to gcp vm from github actions using workload identity federation
r/googlecloud on Reddit: SSH to GCP VM from GitHub Actions using Workload Identity Federation
December 18, 2024 -

Hi, is it possible to SSH into GCP VM instance from GitHub Actions using Workload Identity Federation (therefore use the Service Account tied to it)? Is it even recommended? I tried to use glcoud beta compute sshbut I still could not get it to work (I can provide the details if need be).

My hope is to not have to a use a GCP IAM User in my GitHub Actions workflow (which seems to be required if I want to use OS Login for ssh access). I also don't want to manually save a ssh key in my VM since I would have to do that every time I recreate the VM.

NOTE: I am using terraform and OS Login for bringing up the VM and running commands on it. This is not incorporated into my GitHub actions workflow. In my GitHub actions workflow, I only intend to push a new docker image to registry, SSH into the VM, pull the new Docker image, and recreate the container.

Would appreciate any help, thank you!

🌐
DEV Community
dev.to › shivamjainn › creating-and-deploying-a-google-cloud-run-service-using-artifact-registry-and-github-actions-4jmc
Creating and Deploying a Google Cloud Run Service Using Artifact Registry and GitHub Actions - DEV Community
December 1, 2024 - In your repo, create the .github/workflows directory. Inside, create a file called push_image.yml. name: Deploy to GCP on: push: branches: - master paths: - images/* jobs: build-and-push: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Docker uses: docker/setup-buildx-action@v2 - name: Authenticate with GCP uses: google-github-actions/auth@v2 with: credentials_json: ${{ secrets.GCP_CREDENTIALS }} token_format: 'access_token' - name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v1 - name: Configure Docker for Artifact Registry run: | gcl
🌐
Medium
medium.com › @sultanalkhubayzi › deploying-a-web-app-to-google-compute-engine-with-github-actions-2f5f18423f55
Deploying a Web App to Google Compute Engine with GitHub Actions | by Sultan Alkhubayzi | Medium
April 7, 2025 - Go to your repository → Settings → Secrets and Variables → Actions. Click the “New Repository Secret” button and create the following two secrets: GCP_PROJECT_ID: Your Google Cloud Project ID.