You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: INSTALL.md
+21-41Lines changed: 21 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -8,39 +8,13 @@ To get this Azure Function working, you need to:
8
8
9
9
Once that is done, you can create an Actions workflow on any repository that the GitHub App is installed for, that listens for the `repository_dispatch` event, and does whatever you want it to do.
10
10
11
+
> ℹ️ when working with the Azure CLI, remember to use `az login` to log in to Azure, and `az logout` first if you are having problems
12
+
11
13
## Deploying the Azure Function
12
14
13
15
You need to create an Azure Function App, and deploy the Azure Function to it.
14
16
15
-
Before you deploy, you can choose to set a declarative filter for the GitHub events you want to listen for.
16
-
17
-
This is done in the `fiter.yml` file, with the format shown in `filter.yml.example` and below:
18
-
19
-
```yaml
20
-
# Path: filter.yml
21
-
22
-
# filter webhook events by type and payload, declaratively
23
-
24
-
include:
25
-
secret_scanning_alert:
26
-
action: [created, dismissed, resolved, reopened]
27
-
28
-
exclude:
29
-
secret_scanning_alert:
30
-
action: reopened
31
-
secret_scanning_alert_location:
32
-
33
-
```
34
-
35
-
The corresponding exclude filter for an event name is applied after the include filter.
36
-
37
-
This example will include any event named `secret_scanning_alert` with an action of `created`, `dismissed`, or `resolved`, `reopened` and will exclude any event named `secret_scanning_alert` with an action of `reopened`. It will also exclude any event named `secret_scanning_alert_location`.
38
-
39
-
The presence of an include filter here means that excluding `secret_scanning_alert_location` is redundant, as it will never be included in the first place, but it is included to show the syntax.
40
-
41
-
If you do not want to use a filter, you can delete the `filter.yml` file, or leave it empty.
42
-
43
-
You do not need to provide both an `include` and `exclude` key.
17
+
Before you deploy, set a `filter.yml` if you wish to filter out certain events. See [filtering events](README.md#filtering-events) for more details.
44
18
45
19
### Creating the Functions App
46
20
@@ -71,7 +45,6 @@ AZURE_LOCATION=<location>
71
45
AZURE_STORAGE_ACCOUNT=<storage account name>
72
46
AZURE_FUNCTION_APP_NAME=<function app name>
73
47
74
-
az login
75
48
az account set --subscription "${AZURE_SUBSCRIPTION_ID}"
76
49
az group create --name "${AZURE_RESOURCE_GROUP}" --location "${AZURE_LOCATION}"
@@ -97,7 +70,7 @@ Some of these steps assume you have zipped up the code of this function into `gi
97
70
You can do that using:
98
71
99
72
```bash
100
-
zip -r github-webhook-mirror.zip . -x 'node_modules/*''.vscode/*''dist/*''local.settings.json''.git/*''github-webhook-mirror.zip'
73
+
zip -r github-webhook-mirror.zip . -x '.vscode/*''local.settings.json''.git/*''.github/*''.gitignore''.eslint*''.funcignore''*.md''CODEOWNERS''LICENSE''*.ts''*.js.map''jest.config.js''filter.yml.example''github-webhook-mirror.zip'
101
74
```
102
75
103
76
#### Deploying with the Azure Portal
@@ -112,14 +85,22 @@ Select "Zip Deploy", and upload the `github-webhook-mirror.zip` file.
112
85
113
86
#### Deploying with the Azure CLI
114
87
115
-
> **TODO**: test this
88
+
```bash
89
+
AZURE_FUNCTION_APP_NAME=<function app name>
90
+
91
+
npm run build
92
+
func azure functionapp publish "${AZURE_FUNCTION_APP_NAME}"||echo"Failed to publish function app, try running 'az logout' then 'az login', then try again"
93
+
```
94
+
95
+
That may fail if it can't find the function app. If it does, you can try this alternative.
96
+
97
+
If you have already zipped up the code of this function into `github-webhook-mirror.zip`, you can use:
116
98
117
99
```bash
118
100
AZURE_SUBSCRIPTION_ID=<subscription id>
119
101
AZURE_RESOURCE_GROUP=<resource group name>
120
102
AZURE_FUNCTION_APP_NAME=<function app name>
121
103
122
-
az login
123
104
az account set --subscription "${AZURE_SUBSCRIPTION_ID}"
@@ -148,14 +129,11 @@ That should take you to the Function App's page. You should see your Function li
148
129
149
130
#### Finding the Functions App's URL with the Azure CLI
150
131
151
-
> **TODO**: test this
152
-
153
132
```bash
154
133
AZURE_SUBSCRIPTION_ID=<subscription id>
155
134
AZURE_RESOURCE_GROUP=<resource group name>
156
135
AZURE_FUNCTION_APP_NAME=<function app name>
157
136
158
-
az login
159
137
az account set --subscription "${AZURE_SUBSCRIPTION_ID}"
160
138
az functionapp show --resource-group "${AZURE_RESOURCE_GROUP}" --name "${AZURE_FUNCTION_APP_NAME}" --query "defaultHostName" --output tsv
161
139
```
@@ -194,15 +172,16 @@ You will need a name, a description, a homepage URL (which can just be `https://
194
172
- leave the option selected to "Enable SSL verification"
195
173
- select the events you want to receive, by giving the app the relevant additional permissions, and then selecting which events should be sent to the webhook
196
174
- ⚠️ carefully think about the security implications of giving _anyone with write access_ to your repository access to these events before you choose the events
197
-
- click on the "Generate a private key" button. This will automatically download the private key as a `.pem` file. Save the private key somewhere safe - this is the only time you get to download it, and you will need it later
175
+
- click on the "Generate a private key" button. This will automatically download the private key as a `.pem` file.
176
+
- ⚠️ save the private key somewhere safe - _this is the only time you get to download it_, and you will need it later
198
177
199
178
[The full GitHub docs](https://docs.github.com/en/enterprise-cloud@latest/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) can help you if you get stuck.
200
179
201
180
### Use the GitHub API to create a new GitHub App
202
181
203
182
> **TODO**
204
183
205
-
This is possible [using a manifest](https://docs.github.com/en/enterprise-cloud@latest/apps/sharing-github-apps/registering-a-github-app-from-a-manifest), but has not been implemented.
184
+
This is possible [using a manifest](https://docs.github.com/en/enterprise-cloud@latest/apps/sharing-github-apps/registering-a-github-app-from-a-manifest), but has not yet been implemented here.
206
185
207
186
## Installing the GitHub App
208
187
@@ -217,7 +196,9 @@ You need to install the GitHub App on an organization or repository.
217
196
218
197
> **TODO**
219
198
220
-
This is left until the creation of the app has been implemented.
199
+
This has not been implemented yet.
200
+
201
+
This is left until the creation of the app using a manifest has been implemented.
Copy file name to clipboardExpand all lines: README.md
+33Lines changed: 33 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,39 @@ sequenceDiagram
33
33
- an Azure account on an Azure subscription
34
34
- a GitHub account
35
35
36
+
## Filter events
37
+
38
+
Before you deploy, you can choose to set a declarative filter to apply to GitHub events you receive in the Azure Functions App. This is in addition to selecting the events you choose to listen for in the GitHub App.
39
+
40
+
This is done in the `fiter.yml` file, with the format shown in `filter.yml.example` and below:
41
+
42
+
```yaml
43
+
# Path: filter.yml
44
+
45
+
# filter webhook events by type and payload, declaratively
46
+
47
+
include:
48
+
secret_scanning_alert:
49
+
action: [created, dismissed, resolved, reopened]
50
+
51
+
exclude:
52
+
secret_scanning_alert:
53
+
action: reopened
54
+
secret_scanning_alert_location:
55
+
56
+
```
57
+
58
+
The corresponding exclude filter for an event name is applied after the include filter.
59
+
60
+
This example will include any event named `secret_scanning_alert` with an action of `created`, `dismissed`, or `resolved`, `reopened` and will exclude any event named `secret_scanning_alert` with an action of `reopened`. It will also exclude any event named `secret_scanning_alert_location`.
61
+
62
+
The presence of an include filter here means that excluding `secret_scanning_alert_location` is redundant, as it will never be included in the first place, but it is included to show the syntax.
63
+
64
+
If you do not want to use a filter, you can delete the `filter.yml` file, or leave it empty.
65
+
66
+
You do not need to provide both an `include` and `exclude` key.
0 commit comments