Home > Software engineering >  Connecting github repository with google cloud, push at the same time as well as commits
Connecting github repository with google cloud, push at the same time as well as commits

Time:12-29

I want to connect my GitHub repository to an already made google cloud project with the exact same documents.
I have been searching and using Google Cloud build, but I need docker, the problem is I don't have any container or docker file in the repository.
I know it's made with triggers and pipes, but i don't know how, I am pretty new to this.

Is there something I could do, or is impossible?
All the docs in google cloud are in SSH.

CodePudding user response:

I want that everytime i do a push or a commit from my local to the repo automatically do the change in the google cloud project

That means a GitHub Action, and I do not see one which would directly push to your G-CSR (Google Cloud Source Repository).

You would need to write one, which would:

  • checkout your GitHub repository on push
  • setup gcloud
  • call a script like cloudfunction-python37.sh which will
    • Enable Google Cloud Source Repository API
      gcloud services enable sourcerepo.googleapis.com;
    • Add IAM permissions to default Cloud Build service account
      gcloud iam service-accounts add-iam-policy-binding \
        [email protected] \
        --member="serviceAccount:[email protected]" \
        --role="roles/iam.serviceAccountUser"
      
    • Add Google Cloud Source repository as remote to local Git repository
      git remote add google https://source.developers.google.com/p/$PROJECT_ID/r/$REPO_NAME
    • Do a git push
  • Related