Skip to content

Commit 8820721

Browse files
authored
Merge pull request #2 from advanced-security/scripts
Moved scripts into their own folder
2 parents dc22a05 + c30615f commit 8820721

12 files changed

+51
-27
lines changed

.funcignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LICENSE
1414
jest.config.js
1515
*.example
1616
node_modules/.bin/
17-
*.sh
17+
scripts/
1818
*.env
1919
tsconfig.json
2020
src/

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,5 @@ __azurite_db*__.json
105105
# if you fork this repo, you can uncomment this and commit your own filter.yml
106106
filter.yml
107107

108-
# local example files
109-
*.example
110-
111108
# Azure environment file
112109
azure.env

INSTALL.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ To get this Azure Function working, you need to:
1111

1212
> [!NOTE]
1313
> 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.
14-
>
15-
> To use the convenience scripts, set your Azure settings in a local `azure.env` file that they pick up. You may need to change settings if you want to vary the region the Function is used in, or change its name to allow more than one to coexist in the same subscription.
14+
15+
> [!NOTE]
16+
> To use the Bash (use WSL on Windows for Bash) scripts in the `scripts` directory, set your Azure settings in a `azure.env` file that they pick up from the same directory. You may need to change settings if you want to vary the region the Function is used in, or change its name to allow more than one to coexist in the same subscription.
1617
1718
## Creating a GitHub app
1819

@@ -78,7 +79,7 @@ This is left until the creation of the app using a manifest has been implemented
7879

7980
You need to create an Azure Function App, and deploy the Azure Function to it.
8081

81-
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.
82+
Before you deploy, set a `filter.yml` if you wish to filter out certain events. See [filtering events](README.md) for more details.
8283

8384
### Creating the Functions App
8485

@@ -98,11 +99,11 @@ Fill in the details, and click on the "Review + create" button. Make sure you se
9899

99100
#### Creating the Functions App with the Azure CLI
100101

101-
It needs your subscription ID, a location, and a function app name to be set in `azure.env` in the repo directory.
102+
It needs your subscription ID, a location, and a function app name to be set in `scripts/azure.env` in the repo directory.
102103

103104
Only the subscription ID is necessary - the rest have defaults: you may want to change the region or the name of the function.
104105

105-
You can use the convenience script `create-azure-function.sh`.
106+
You can use the convenience script `scripts/create-azure-function.sh`.
106107

107108
#### Creating the Functions App with the VSCode Azure Functions extension
108109

filter.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

scripts/azure.env.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Save as: azure.env
2+
3+
# if you want to use a different location than eastus, you can change this
4+
AZURE_LOCATION="eastus"
5+
6+
# fill in your Azure subscription ID
7+
AZURE_SUBSCRIPTION_ID="..."
8+
9+
# pick an appropriate name for the function app
10+
AZURE_FUNCTION_APP_NAME="teams-secret-scanning-notifier"
11+
12+
# pick an appropriate name for a new resource group
13+
AZURE_RESOURCE_GROUP="${AZURE_FUNCTION_APP_NAME}-rg"

create-function-app.sh renamed to scripts/create-function-app.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
set -euo pipefail
44

5-
. ./azure.env
5+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6+
7+
. "${SCRIPT_DIR}"/azure.env
68

79
# set Azure location to us-east unless it is set to something different already
810
AZURE_STORAGE_ACCOUNT="${AZURE_STORAGE_ACCOUNT:-teamssecretnotifier001sa}"
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/bash
22

3-
. ./azure.env
3+
set -euo pipefail
4+
5+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6+
7+
. "${SCRIPT_DIR}"/azure.env
8+
9+
./make-function-zip.sh
410

511
az account set --subscription "${AZURE_SUBSCRIPTION_ID}"
612
az functionapp deployment source config-zip --resource-group "${AZURE_RESOURCE_GROUP}" --name "${AZURE_FUNCTION_APP_NAME}" --src teams-secret-scanning-notifier.zip
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22

3-
. ./azure.env
3+
set -euo pipefail
4+
5+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6+
7+
. "${SCRIPT_DIR}"/azure.env
48

59
npm run build
610
func azure functionapp publish "${AZURE_FUNCTION_APP_NAME}" || echo "Failed to publish function app, try running 'az logout' then 'az login', then try again"

get-function-url.sh renamed to scripts/get-function-url.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22

3-
. ./azure.env
3+
set -euo pipefail
4+
5+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6+
7+
. "${SCRIPT_DIR}"/azure.env
48

59
az account set --subscription "${AZURE_SUBSCRIPTION_ID}"
610
FUNCTIONS_APP_HOSTNAME=$(az functionapp show --resource-group "${AZURE_RESOURCE_GROUP}" --name "${AZURE_FUNCTION_APP_NAME}" --query "defaultHostName" --output tsv)

make-function-zip.sh renamed to scripts/make-function-zip.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ zip -q -r teams-secret-scanning-notifier.zip . \
1010
-x 'teams-secret-scanning-notifier.zip' '.vscode/*' '*settings*.json' \
1111
'.git/*' '.github/*' '.gitignore' '.eslint*' '.funcignore' '*.md' \
1212
'CODEOWNERS' 'LICENSE' '*.ts' '*.map' 'jest.config.js' \
13-
'*.example' 'node_modules/.bin/*' '*.sh' '*.env' \
13+
'*.example' 'node_modules/.bin/*' 'scripts/*' '*.env' \
1414
'tsconfig.json' 'src/*' 'test/*' \
1515
'node_modules/@types/*' 'node_modules/*jest*/*' \
1616
'node_modules/*eslint*/*' '*/.github/*' '*/.history/*' \

0 commit comments

Comments
 (0)