Skip to content

Update README.md

Update README.md #21

Workflow file for this run

name: Deploy to Google Cloud
on:
push:
branches:
- main # Trigger deployment on push to main branch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Google Cloud SDK
uses: google-github-actions/[email protected]
with:
version: 'latest'
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: Ensure SSH key exists
run: |
mkdir -p ~/.ssh
if [ ! -f ~/.ssh/google_compute_engine ]; then
ssh-keygen -t rsa -f ~/.ssh/google_compute_engine -C "${{ github.actor }}" -N ""
fi
env:
CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
- name: Add SSH key for Google Cloud
run: |
gcloud compute os-login ssh-keys add --key-file ~/.ssh/google_compute_engine.pub --project ${{ secrets.PROJECT_ID }}
env:
CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
- name: Debug SSH keys
run: gcloud compute os-login ssh-keys list --project ${{ secrets.PROJECT_ID }}
env:
CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
- name: Add SSH key to SSH agent
run: |
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/google_compute_engine
- name: Deploy to Google Compute Engine
run: |
gcloud compute ssh trouys16@${{ secrets.INSTANCE_NAME }} --project ${{ secrets.PROJECT_ID }} --zone ${{ secrets.ZONE }} --command "/home/trouys16/deploy.sh"