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 - Artifact build stage: use language-specific tooling (gradle, sbt, npm, etc.) to build an application artifact · Packaging stage: bundle the application artifact with any other required components/dependencies · Containerization stage: create a container image containing the application package · Release creation stage: use the Cloud Deploy GitHub Action to create a release of the built container image
Discussions

Continuous deployment from GitHub Action to Google Cloud VM using Docker - Stack Overflow
For university, I am creating quite a simple project using Node.js. What I want is to set up a continuous delivery to a virtual machine hosted in the Google Cloud. Using the GitHub Actions, I creat... More on stackoverflow.com
🌐 stackoverflow.com
google cloud platform - How to deploy GCP compute vm server using github actions terraform - Stack Overflow
Github actions with a Terraform workflow (not Terraform cloud) to deploy a GCP compute engine VM server. My workflow currently errors out on the Terraform Format process. The main.tf I know works i... More on stackoverflow.com
🌐 stackoverflow.com
SSH to GCP VM from GitHub Actions using Workload Identity Federation
I have documented a similar use case in chapter 2 of my PCSE book using this example. Have you tried this approach? https://github.com/google-github-actions/auth/blob/main/README.md More on reddit.com
🌐 r/googlecloud
4
4
December 18, 2024
Github actions to google cloud run takes about 7 mins. Is that normal?
I haven't worked with these particular GitHub Actions myself, but two things that you could try: Looking at google-github-actions/setup-gcloud, the latest version appears to be v2.1.1. ( https://github.com/google-github-actions/setup-gcloud/tags ). Perhaps it is worth trying v2.1.1 rather than v0.2.1 which is 3+ years old. Potentially, there are speed improvements there. For the Docker container building process, you'd have to review the Dockerfile and see whether you can perform any optimizations. Can you remove unnecessary dependencies? Can you utilize multi-stage builds to decrease the image size? ( https://docs.docker.com/build/building/multi-stage/ ) More on reddit.com
🌐 r/devops
9
9
October 1, 2024
🌐
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.
🌐
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 583 users
Forked by 136 users
Languages   TypeScript 95.4% | JavaScript 2.8% | Dockerfile 1.8%
🌐
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.
🌐
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
This is a GitHub Action that can deploy any Docker-based app to a Google Cloud VM using Docker and Docker Compose. ... Create a new VM in your Google Cloud account. Copy this repo to the VM.
Author   bitovi
Find elsewhere
🌐
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.
🌐
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.
🌐
Medium
medium.com › @burgossrodrigo › automating-ssh-into-gcp-vms-using-github-actions-539915ca3164
Automating SSH into GCP VMs Using GitHub Actions | by Burgossrodrigo | Medium
April 14, 2024 - Replace username with your GCP username and your-vm-ip with your VM's external IP address. Commit and push your changes to the GitHub repository to trigger the workflow. GitHub Actions will execute the workflow and SSH into your VM to run your ...
🌐
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 - The following workflow step will build the container image and tag it with the GitHub reference commit hash. This is to keep track of the latest image while also keeping commit history and images aligned. It is important to note the context attribute in this step tells the action where to look for the source code relative to the current working directory. Please see this repository for more information on the docker build push action. ... In any application deployment, it is common to have controls on who can deploy to production and when.
🌐
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%
🌐
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).
🌐
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!

🌐
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 - Integrating GitHub Actions with GCP allows you to automate various tasks, such as retrieving secrets, which is essential for maintaining security and efficiency in your development workflow. This method ensures centralized and controlled access management, reducing the risks associated with manual operations. 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: read steps: - name: 'Checkout code' uses: 'ac
🌐
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.
🌐
Medium
adyatma-nugrahayudha.medium.com › deploy-your-app-with-docker-github-actions-and-google-cloud-platform-1d90c9a7b793
Deploy Your App with Docker, GitHub Actions, and Google Cloud Platform | by Adyatma Nugraha Yudha | Medium
March 10, 2024 - Step 2: Creating Workflow File Within your GitHub repository, navigate to the .github/workflows directory (create it if it doesn't exist) and create a new YAML file for your GitHub Actions workflow. This file will define the series of steps to be executed whenever a trigger event occurs, such as a code push or pull request. name: Deploy Django to GCP with Docker - Staging on: push: branches: - staging env: SECRET_KEY: ${{ vars.SECRET_KEY }} ENVIRONMENT: ${{ vars.ENVIRONMENT }} jobs: build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 test: needs: build ru
🌐
GitHub
github.com › google-github-actions › deploy-cloud-functions
GitHub - google-github-actions/deploy-cloud-functions: A GitHub Action that deploys source code to Google Cloud Functions. · GitHub
jobs: job_id: permissions: contents: 'read' id-token: 'write' steps: - uses: 'actions/checkout@v4' - id: 'auth' uses: 'google-github-actions/auth@v3' with: project_id: 'my-project' workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider' - id: 'deploy' uses: 'google-github-actions/deploy-cloud-functions@v4' timeout-minutes: 10 with: name: 'my-function' runtime: 'nodejs22' 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 334 users
Forked by 69 users
Languages   TypeScript 96.9% | JavaScript 3.1%