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

Cloudbuild trigger tied to a github repo, but invoked manually. #10779

Comments

@jgunnink
Copy link

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

Creating a cloudbuild trigger that is tied to a github repo, but invoked manually.

I am trying to build a cloudbuild trigger that is tied to a github repo, but is triggered manually. When code changes occur I do not want the build job to start, there’s a separate process that invokes the trigger and causes the build to start.

At the moment, the github block requires the user to:

Specify only one of pullRequest or push

In the console, it is possible to create a cloudbuild trigger that is tied to github and invoked manually. Observing the request and reading the API Documentation, it is possible to do this via the API also. Although, not via the gcloud CLI.

Calling POST at https://cloudbuild.googleapis.com/v1/projects/{projectId}/triggers with the sample payload:

{
  "name": "test",
  "description": "a test trigger that is tied to github but invoked manually",
  "disabled": false,
  "sourceToBuild": {
    "uri": "https://github.com/owner/repo",
    "repoType": "GITHUB",
    "ref": "refs/heads/master"
  },
  "gitFileSource": {
    "uri": "https://github.com/owner/repo",
    "repoType": "GITHUB",
    "revision": "refs/heads/master",
    "path": "cloudbuild.yaml"
  }
}

Results in a 200, with the following response:

{
  "id": "a5c98ecc-364f-4248-ab2b-4e9746f9c4c4",
  "createTime": "2021-12-20T23:59:27.657698307Z",
  "description": "a test trigger that is tied to github but invoked manually",
  "name": "test",
  "gitFileSource": {
    "path": "cloudbuild.yaml",
    "uri": "https://github.com/owner/repo",
    "repoType": "GITHUB",
    "revision": "refs/heads/master"
  },
  "sourceToBuild": {
    "uri": "https://github.com/owner/repo",
    "ref": "refs/heads/master",
    "repoType": "GITHUB"
  }
}

New or Affected Resource(s)

resource_cloubuild_trigger.go

Potential Terraform Configuration

resource "google_cloudbuild_trigger" "my-manual-trigger-github" {
  name        = "my-manual-trigger-github"
  description = "Run terraform plan on pull requests against master"

  github {
    owner   = var.repo_owner
    name    = var.repo_name
    trigger = "manual"
  }

  filename = "cloudbuild.yaml"
}

References

@c2thorn
Copy link
Collaborator

c2thorn commented Jan 31, 2022

It seems like this feature request boils down to to a request for gitFileSource and sourceToBuild fields.

@c2thorn c2thorn added the size/m label Jan 31, 2022
@c2thorn c2thorn removed their assignment Jan 31, 2022
@rileykarson rileykarson added this to the Goals milestone Jan 31, 2022
@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

@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.