Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google_cloudbuild_trigger add fields sourceToBuild and GitFileSource #9883

Comments

@frehov
Copy link

frehov commented Aug 23, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Cloud build has updated their api spec , and added the fields sourceToBuild and GitFileSource.
In the referenced issue, the webhook trigger needs these fields to set up a working trigger.

The property GitfileSource can most likely be inferred from filename and sourceToBuild, as the sourceToBuild contains 75% of what's needed in the GitFileSource, combining with filename, it should provide the full field.

New or Affected Resource(s)

  • google_cloudbuild_trigger

Potential Terraform Configuration

# Propose what you think the configuration to take advantage of this feature should look like.
# We may not use it verbatim, but it's helpful in understanding your intent.

resource "google_secret_manager_secret" "sanity_webhook_secret" {
  secret_id = "sanity_webhook_secret"
  labels    = {}

  replication {
    automatic = true
  }
}

data "google_secret_manager_secret_version" "sanity_webhook_secret_content" {
  secret = google_secret_manager_secret.sanity_webhook_secret.id
}

resource "google_cloudbuild_trigger" "website-sanity-deploy-dev" {
   provider    = google
   name        = "sanity-webhook-trigger-dev"
   description = "Trigger build on changes from sanity"
   filename    = ".cloudbuild/gatsby_sanity_build.yml"

   build_source = {
     uri = "<path to github repo>"
     ref = "" # this should probably be branch, and instead add "/refs/heads/<branchname>" in code, no regex allowed.
     type = "GITHUB"
   }

   webhook_config {
     secret = data.google_secret_manager_secret_version.sanity_webhook_secret_content.name
   }

   substitutions = {
     _DIR = "website/"
     _BUILD_ENV = "development"
     _NODE_VERSION = "12-alpine3.12"
     _SUPPRESS_OUTPUT = "true"
   }
}

References

@jcanseco
Copy link
Contributor

We'd also like to request support for the sourceToBuild field from the API to allow users to create PubSub-based triggers that are configured to build GitHub repositories (customer request).

I talked to the Cloud Build team, and it turns out that to accomplish the above use-case, users would need to specify the pubsubConfig field (to configure the trigger to be triggered by PubSub messages) and the sourceToBuild field (to configure the GitHub repo to build).

@pattishin
Copy link

pattishin commented Dec 3, 2021

Would like to bump this up as I'm facing a similar use-case as @jcanseco to use this in tandem with pubsub_config. Anyway to get a clear picture of where this issue sits in the priority queue for the team? Any insight would be greatly appreciated!

Ref: https://cloud.google.com/build/docs/api/reference/rest/v1/projects.locations.triggers#BuildTrigger.GitFileSource

@enchorb
Copy link

enchorb commented Dec 31, 2021

Bump, need this for webhook_config. Currently need to manually specify the repo to build from once a webhook event is received

@abhinavrau
Copy link

I would like to work on this issue. I have added support for it on my fork of magic-modules here. I will be submitting a PR soon

@mariomachado94
Copy link

@abhinavrau I too was working on this, oh no.

@abhinavrau
Copy link

Sorry @mariomachado94. I guess we both had a need to fix this long outstanding issue. Please let me know thoughts on my solution and how it could be better. I would really appreciate it. Fingers crossed if my solution passes all the tests!

@github-actions
Copy link

github-actions bot commented Apr 4, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.