Skip to content

Commit 7f29fa6

Browse files
author
Shivam Mukhade
committed
Update webhook CLI docs
Signed-off-by: Shivam Mukhade <[email protected]>
1 parent 9c17948 commit 7f29fa6

File tree

3 files changed

+33
-25
lines changed

3 files changed

+33
-25
lines changed

docs/content/docs/install/github_webhook.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ After configuring the webhook, you will be able to update the token in the secre
5252

5353
Alternatively, you could follow the [Setup Git Repository manually](#setup-git-repository-manually) guide to do it manually
5454

55-
### Setup Git Repository manually
55+
## Setup Git Repository manually
5656

5757
follow below instruction to configure webhook manually
5858

@@ -113,11 +113,11 @@ follow below instruction to configure webhook manually
113113
# key: "webhook.secret"
114114
```
115115

116-
### GitHub webhook Notes
116+
## GitHub webhook Notes
117117

118118
* Secrets need to be in the same namespace as installed on Repository, they cannot be on another namespace.
119119

120-
### Update Token
120+
## Update Token
121121

122122
When you have regenerated a new token you will need to update it on cluster.
123123
For example through the command line, you will want to replace `$NEW_TOKEN` and `$target_namespace` by their respective values:
@@ -132,5 +132,5 @@ You can find the secret name in Repository CR created.
132132
```
133133
134134
```shell
135-
kubectl -n $target_namespace patch secret githubwebhook -p "{\"data\": {\"foo\": \"$(echo -n $NEW_TOKEN|base64 -w0)\"}}"
135+
kubectl -n $target_namespace patch secret github-webhook-config -p "{\"data\": {\"provider.token\": \"$(echo -n $NEW_TOKEN|base64 -w0)\"}}"
136136
```

docs/content/docs/install/gitlab.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: Gitlab
33
weight: 13
44
---
55

6-
# Install Pipelines-as-Code for Gitlab
6+
# Use Pipelines-as-Code with Gitlab Webhook
77

88
Pipelines-As-Code supports [Gitlab](https://www.gitlab.com) through a webhook.
99

1010
Follow the pipelines-as-code [installation](/docs/install/installation) according to your kubernetes cluster.
1111

12-
## Generate a token for Pipelines as Code
12+
## Create GitHub Personal Access Token
1313

1414
* You will have to generate a personal token as the manager of the Org or the Project,
1515
follow the steps here :
@@ -22,28 +22,19 @@ Follow the pipelines-as-code [installation](/docs/install/installation) accordin
2222
to fallback nicely by showing the status of the pipeline directly as comment
2323
of the Merge Request.
2424

25-
{{< hint danger >}}
26-
For best security practice you will probably want to have a short token
27-
expiration (like the default 30 days). Gitlab will send you a notification email
28-
if you token expires. When you have regenerated a new token you will need to
29-
update it on cluster. For example through the command line, you will want to replace
30-
`$NEW_TOKEN` and `$target_namespace` by their respective values:
25+
## Setup Git Repository
3126

32-
```shell
33-
kubectl -n $target_namespace patch secret gitlabwebhook -p "{\"data\": {\"foo\": \"$(echo -n $NEW_TOKEN|base64 -w0)\"}}"
34-
```
27+
Now, you have 2 ways to set up the repository and configure the webhook:
3528

36-
{{< /hint >}}
29+
You could use [`tkn pac repository create`](/docs/guide/cli) command which
30+
will create repository CR and configure webhook.
3731

38-
## Repository creation
32+
You need to have a personal access token created with `admin:repo_hook` scope. tkn-pac will use this token to configure the
33+
webhook and add it in a secret on cluster which will be used by pipelines-as-code controller for accessing the repository.
3934

40-
Now, you have 2 ways to configure the webhook:
35+
Alternatively, you could follow the [Setup Git Repository manually](#setup-git-repository-manually) guide to do it manually
4136

42-
* You could use [`tkn pac repository create`](/docs/guide/cli) command which
43-
will create repository CR and configure webhook, or
44-
* You could follow the [configuring webhook](#configure-webhook) guide to do it manually
45-
46-
## Configure webhook
37+
## Setup Git Repository manually
4738

4839
* Go to your project and click on *Settings* and *"Webhooks"* from the sidebar on the left.
4940

@@ -110,3 +101,21 @@ Here is an example of a Repository CRD :
110101
* `git_provider.secret` cannot reference a secret in another namespace,
111102
Pipelines as code always assumes it will be the same namespace as where the
112103
repository has been created.
104+
105+
## Update Token
106+
107+
When you have regenerated a new token you will need to update it on cluster.
108+
For example through the command line, you will want to replace `$NEW_TOKEN` and `$target_namespace` by their respective values:
109+
110+
You can find the secret name in Repository CR created.
111+
112+
```yaml
113+
spec:
114+
git_provider:
115+
secret:
116+
name: "gitlab-webhook-config"
117+
```
118+
119+
```shell
120+
kubectl -n $target_namespace patch secret gitlab-webhook-config -p "{\"data\": {\"provider.token\": \"$(echo -n $NEW_TOKEN|base64 -w0)\"}}"
121+
```

pkg/cli/webhook/github.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ func (gh *gitHubConfig) askGHWebhookConfig(repoURL, controllerURL, apiURL string
103103
return err
104104
}
105105

106-
fmt.Fprintln(gh.IOStream.Out, "ℹ ️You now need to create a GitHub personal token with scopes `public_repo` & `admin:repo_hook`")
107-
fmt.Fprintln(gh.IOStream.Out, "ℹ ️Go to this URL to generate a new token https://github.com/settings/tokens/new, see https://is.gd/G5gBFI for documentation ")
106+
fmt.Fprintln(gh.IOStream.Out, "ℹ ️You now need to create a GitHub personal access token, please checkout the docs at https://is.gd/KJ1dDH for the required scopes")
108107
if err := prompt.SurveyAskOne(&survey.Password{
109108
Message: "Please enter the GitHub access token: ",
110109
}, &gh.personalAccessToken, survey.WithValidator(survey.Required)); err != nil {

0 commit comments

Comments
 (0)