Skip to content

Commit 8d955a8

Browse files
authored
Workflow changes for controller deploy workflow (#12)
* fix: recover soft deleted key to true * fix: recover soft deleted key to false * chore: Add max queue polling to 2 mins * chore: Change controller workflow * chore: Change controller workflow * chore: Change controller workflow * chore: Change controller workflow * chore: Change controller workflow * fix: Change container group function * fix: Correct docker image * chore: Parse webhook json * fix:correct sending proper label to queue * fix:create missing function'; * fix:correct variale scope * feat: Add kv role assignment to controller app * fix: Enable RBAC for Azure KV * fix: container_name * debug: hard code container name * debug: hard code image name * fix: correct env variable for controller app * fix: Correct KV role to contributor * fix: Correct KV role to admin * fix: Correct KV role to admin * fix: Correct KV role to admin * fix: Correct KV role to admin * feat: Add RBAC for key vault * feat: Add RBAC for key vault * feat: Add RBAC for key vault * feat: Add env variable * feat: Add acr credentials * feat: Add system managed role for acr * feat: Add user assigned identity * feat: Add user assigned identity * feat: Add user assigned identity * feat: Assign identity operator role to controller app * fix: correct user identity name * fix: correct image name * fix: correct image name * fix: correct image name * fix: correct image name * fix: Correct image name * debug: Add identity separated from group * debug: add nginx image * debug: make acr admin enabled * debug: revert to actual acr image * feat: admin enable acr * fix: Add acr cred to app env var * fix: add admin image cred * fix: Correct image name * fix: Removed user assigned identity * fix: Add version to azure container management lib * fix: Correct image registry cred injection * debug: log acr details for debugging * fix:Correct image registry cred * fix:Correct image registry cred * fix:Correct image registry cred * fix:Correct image registry cred * fix: Broken runner image registration * fix: Add gh orh variable * fix: Add gh orh variable * fix: Correct docker image name * feat: Add log analytics ws for container group * fix: Correct token generations and usage * chore: remove commented code * fix: remove log analytics * fix: Correct setting runner token * fix: Correct image name * fix: Correct app param * fix: Correct app param * fix: Add workflow id to container group name * fix: correctly parse input json * feat: Added delete container group for terminated CG * feat: Add app param for receiver * feat: Add app param for receiver * feat: Add app param for receiver * fix: revert to non termination * fix: req file * debug: comment code * change workflow name * corrected workflow * corrected workflow * corrected workflow * corrected workflow * corrected workflow * corrected workflow * corrected workflow * corrected workflow * corrected workflow * corrected workflow * feat:Add cleanup infra anf function * fix:controller app workflow * fix: Update name of wf * fix:Try oryx build * fix: add pip command * fix: add pip command * fix: add pip command * fix: add pip command * Update build_deploy_controller_function.yml * Add or update the Azure App Service build and deployment workflow config * fix: workflow yml * fix: workflow yml * fix: workflow yml * test commit * fix: workflow yml * fix: workflow yml * fix: workflow yml * fix: workflow yml * fix: controller app deploy * fix: stop prebuild package * fix: add clean fn role assgnnt * fix: add clean fn role assgnnt * fix: add clean fn role assgnmnt * fix: add clean fn role assgnmnt * fix: add clean fn role assgnmnt * fix: cleanup lambda * feat:Update gitignore * feat: Add readme * chore: Update readme * chore: Update readme * feat: Add workflow id parameter to image name * fix: controller workflow * fix: controller fn * fix : workflow * fix: remove conflicting setting * fix: cont workflow * fix: cont workflow * fix: controller * fix: controller * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix
1 parent 716f20d commit 8d955a8

File tree

8 files changed

+129
-58
lines changed

8 files changed

+129
-58
lines changed
Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,55 @@
1-
21
name: Build and deploy Controller Function
32
run-name: Build and deploy Controller Function
3+
44
on:
55
push:
66
paths:
77
- github-runner-controller-function/**
8-
98
workflow_dispatch:
109

1110
permissions:
12-
id-token: write
13-
contents: read
11+
id-token: write
12+
contents: read
1413

1514
defaults:
1615
run:
1716
shell: bash
1817
working-directory: github-runner-controller-function
1918

2019
env:
21-
AZURE_FUNCTIONAPP_PACKAGE_PATH: './github-runner-controller-function' # set this to the path to your web app project, defaults to the repository root
22-
PYTHON_VERSION: '3.11' # set this to the python version to use (supports 3.6, 3.7, 3.8)
23-
# AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
24-
# AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
25-
# AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
20+
AZURE_FUNCTIONAPP_NAME: 'awesomeproj-dev-controller-function-app'
21+
AZURE_FUNCTIONAPP_PACKAGE_PATH: './github-runner-controller-function' # working-directory already set to this
22+
PYTHON_VERSION: '3.11'
2623

2724

2825
jobs:
2926
build-and-deploy:
3027
runs-on: ubuntu-latest
3128
environment: dev
32-
steps:
33-
- name: Checkout repository
34-
uses: actions/checkout@v4
3529

36-
- name: Setup Python version
37-
uses: actions/setup-python@v5
30+
steps:
31+
- name: 'Checkout Controller Function'
32+
uses: actions/checkout@v3
3833
with:
39-
python-version: ${{ env.PYTHON_VERSION }}
34+
sparse-checkout:
35+
github-runner-controller-function
4036

41-
- name: Create and start virtual environment
37+
- name: list
4238
run: |
43-
python -m venv venv
44-
source venv/bin/activate
45-
46-
- name: pwd
47-
run: pwd
48-
49-
- name: ls -l
50-
run: ls -l
51-
52-
- name: Install dependencies
53-
run: pip install -r requirements.txt
54-
55-
# Optional: Add step to run tests here
39+
echo "=== Repository structure ==="
40+
ls -la
5641
57-
- name: Login to Azure
42+
- name: 'Login via Azure CLI'
5843
uses: azure/login@v2
5944
with:
6045
client-id: ${{ secrets.AZURE_CLIENT_ID }}
6146
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
6247
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
6348

64-
- name: 'Deploy to Azure Functions'
49+
- name: 'Run Azure Functions Action'
6550
uses: Azure/functions-action@v1
66-
id: deploy-to-function
6751
with:
6852
app-name: 'awesomeproj-dev-controller-function-app'
6953
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
54+
remote-build: true
7055

71-
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test Deploy Controller Function
2+
run-name: Test Deploy Controller Function
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
id-token: write
8+
contents: read
9+
10+
jobs:
11+
test-deploy:
12+
runs-on: ubuntu-latest
13+
environment: dev
14+
15+
steps:
16+
- name: 'Checkout Repository'
17+
uses: actions/checkout@v4
18+
19+
- name: 'Login via Azure CLI'
20+
uses: azure/login@v2
21+
with:
22+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
23+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
24+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
25+
26+
- name: 'List files before deployment'
27+
run: |
28+
echo "=== Repository structure ==="
29+
ls -la
30+
echo "=== Controller function directory ==="
31+
ls -la github-runner-controller-function/
32+
33+
- name: 'Deploy using zip'
34+
run: |
35+
cd github-runner-controller-function
36+
# Remove development artifacts
37+
rm -rf .venv .vscode __pycache__ .pytest_cache .git* *.pyc
38+
# Create deployment package
39+
zip -r ../controller-function.zip . -x "*.git*" "*/__pycache__/*" "*.pyc"
40+
cd ..
41+
42+
# Deploy using Azure CLI
43+
az functionapp deployment source config-zip \
44+
--resource-group "awesomeproj-dev-rg" \
45+
--name "awesomeproj-dev-controller-function-app" \
46+
--src controller-function.zip

.gitignore

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,62 @@
11
.sensitive.sh
22

3+
# Terraform state files
34
terraform.tfstate
45
terraform.tfstate.backup
56
.terraform/
67
*.pem
78
.terraform.lock.hcl
9+
terraform.tfvars.backup
10+
*.auto.tfvars
11+
.terraform.d/
12+
13+
# Secrets and sensitive files
814
secrets.json
9-
.venv
10-
destroyplan
1115
secret.*
12-
test_http_function.http
13-
.vscode
16+
*.key
17+
*.p12
18+
*.pfx
19+
.env
20+
.env.*
21+
22+
# Python virtual environments and packages
23+
.venv/
24+
venv/
25+
env/
26+
ENV/
27+
.python_packages/
28+
.conda/
29+
*.pyc
30+
*.pyo
31+
*.pyd
1432
__pycache__/
33+
.pytest_cache/
34+
.coverage
35+
htmlcov/
36+
37+
# Azure and development files
38+
destroyplan
39+
tfplan.out
40+
*.out
41+
test_http_function.http
42+
local.settings.json
43+
.funcignore
44+
45+
# IDE and editor files
46+
.vscode/
47+
.idea/
48+
*.swp
49+
*.swo
50+
*~
51+
.DS_Store
52+
Thumbs.db
53+
54+
# Log files
55+
*.log
56+
logs/
57+
58+
# Temporary files
59+
tmp/
60+
temp/
61+
.tmp/
62+

create-azure-infra/main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ resource "azurerm_linux_function_app" "gha_runner_controller_function_app" {
8080
"QUEUE_NAME" = azurerm_storage_queue.gh_runner_asq.name
8181
"APPINSIGHTS_INSTRUMENTATIONKEY" = azurerm_application_insights.gha_runner_aai.instrumentation_key
8282
"storageAccountConnectionString" = azurerm_storage_account.gha_runner_sa.primary_connection_string
83-
# "WEBSITE_RUN_FROM_PACKAGE" = "1"
84-
"ENABLE_ORYX_BUILD" = "true"
85-
"SCM_DO_BUILD_DURING_DEPLOYMENT" = "true"
83+
# "WEBSITE_RUN_FROM_PACKAGE" = 1
84+
"SCM_DO_BUILD_DURING_DEPLOYMENT" = true
85+
"ENABLE_ORYX_BUILD" = true
86+
8687
}
8788

8889
#zip_deploy_file = "./gha-runner-controller.zip"

github-runner-controller-function/function_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def create_container_instance(runner_label, workflow_job_id):
8686
# Retrieve GH APP secrets from key-vault
8787
container_environment_variable, image_registry_credentials = retrieve_kv_secret()
8888

89-
container_image_name="awesomeprojdevacr.azurecr.io/gha-runner:latest"
89+
container_image_name=f"awesomeprojdevacr.azurecr.io/{runner_label}:latest"
9090

9191
# Configure the container
9292
container_resource_requirements = ResourceRequirements(

github-runner-controller-function/requirements.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
# Manually managing azure-functions-worker may cause unexpected issues
44

55
azure-functions
6-
azure-storage-queue
7-
azure-mgmt-containerinstance>=10.0.0
8-
azure-identity
9-
azure-keyvault-secrets
10-
azure-mgmt-containerregistry
11-
azure.containerregistry
6+
azure-identity>=1.20.0
7+
azure-core>=1.32.0
8+
azure-storage-queue>=12.12.0
9+
azure-keyvault-secrets>=4.9.0
10+
azure-containerregistry>=1.2.0
11+
azure-mgmt-containerinstance>=10.1.0
12+
azure-mgmt-containerregistry>=10.3.0
13+
azure-mgmt-core>=1.5.0
14+

github-runner-controller-function/test.http

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

test.http

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

0 commit comments

Comments
 (0)