Skip to content

Commit 63baf8e

Browse files
authored
Try to make archive retrival work (#32)
* add docs how you can use your local storage to work * add secrets support * add secrets support and update packages * add new endpoint so an azure event grid can send if a blob was changed in the tier * implement the frontend side to retrive blobs * cleanup new file * cleanup function * let retrival of blobs rock! * try to fix the pipeline. (this solution would be sad) * cleanup devocontainers file and update it to the latest and greatest * add github actions extensions * try to use build artifacts * start to make changes to main.bicep * try to make the yaml more robust * fix main.yaml * try to fix the deployment scripts * fix dev container * try to maybe improve deployment for linux * try to fix deploy.ps1 paths for zip deploy * now the bicep file is able to deploy for the current PR the app * fix current deployment * make it possible to deploy from main path too * add deploy.ps1 to the github release * make the bicep stuff more production ready * change hostname to base url * deploy events for PR branches automatically * remove a hack we needed befor * try to fix deployment * try to fix supported version numbers * try to fix the infra deployment * fix bicep template for the event subscriptions * fix pr commenting * try to fix the comments * make our deployment more modular * update the build pipline to be more efficent * fix build pipeline * fix dotnet build / publish. * try to fix azure deployment * fix deploy web app script * try to fix deployment * fix even more parameters * try to use the correct URL to download things while PR is running * try it again * add debugging * debug more * maybe this helps * fix deployment * try it again * fix web app deployment * try to add more debug information * fix a long implemented bug * fix event deployment * try it again * fix deployment * fix cors * try to fix the output of the correct URL * try to fix the output * replace static strings with variables * fix output for main branch too * fix main deployment * add https to the comment url * make the change back to use variables * fix some of the small bugs at the download page * improve the extension collection * try to clear the list better * make improvements to the development container so it's easier to try out things localy * fix a list bug on the download page. Improve the logging a bit
1 parent 1fde08e commit 63baf8e

22 files changed

+895
-247
lines changed

.devcontainer/devcontainer.json

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,63 @@
44
"name": "C# (.NET)",
55
"build": {
66
"dockerfile": "Dockerfile",
7-
"args": {
7+
"args": {
88
// Update 'VARIANT' to pick a .NET Core version: 3.1, 5.0, 6.0
99
// Append -bullseye or -focal to pin to an OS version.
10-
"VARIANT": "6.0",
10+
"VARIANT": "7.0",
1111
// Options
1212
"NODE_VERSION": "lts/*"
1313
}
1414
},
15+
"features": {
16+
"ghcr.io/devcontainers/features/powershell": {
17+
"version": "latest"
18+
},
19+
"ghcr.io/devcontainers/features/dotnet": {
20+
"version": "7.0",
21+
"additionalVersions": "6.0",
22+
"runtimeOnly": false
23+
},
24+
"ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools": {
1525

16-
// Set *default* container specific settings.json values on container create.
17-
"settings": {
18-
"dotnetAcquisitionExtension.existingDotnetPath": [
19-
{
20-
"extensionId": "ms-azuretools.vscode-bicep",
21-
"path": "/usr/share/dotnet/dotnet"
22-
}
23-
]
24-
},
25-
26-
// Add the IDs of extensions you want installed when the container is created.
27-
"extensions": [
28-
"ms-dotnettools.csharp",
29-
"ms-azuretools.vscode-bicep",
30-
"cschleiden.vscode-github-actions",
31-
"ms-azure-devops.azure-pipelines"
32-
],
26+
},
27+
"ghcr.io/devcontainers/features/docker-in-docker": {
3328

29+
}
30+
},
31+
"customizations": {
32+
"vscode": {
33+
// Set *default* container specific settings.json values on container create.
34+
"settings": {
35+
"dotnetAcquisitionExtension.existingDotnetPath": [
36+
{
37+
"extensionId": "ms-azuretools.vscode-bicep",
38+
"path": "/usr/share/dotnet/dotnet"
39+
}
40+
]
41+
},
42+
// Add the IDs of extensions you want installed when the container is created.
43+
"extensions": [
44+
"ms-dotnettools.csharp",
45+
"ms-azuretools.vscode-azurefunctions",
46+
"ms-azuretools.vscode-bicep",
47+
"cschleiden.vscode-github-actions",
48+
"ms-azure-devops.azure-pipelines",
49+
"github.vscode-github-actions",
50+
"ms-vscode.powershell"
51+
]
52+
}
53+
},
3454
// Use 'forwardPorts' to make a list of ports inside the container available locally.
3555
// "forwardPorts": [5000, 5001],
36-
3756
// [Optional] To reuse of your local HTTPS dev cert:
3857
//
3958
// 1. Export it locally using this command:
4059
// * Windows PowerShell:
4160
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
4261
// * macOS/Linux terminal:
4362
// dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere"
44-
//
63+
//
4564
// 2. Uncomment these 'remoteEnv' lines:
4665
// "remoteEnv": {
4766
// "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere",
@@ -56,13 +75,8 @@
5675
//
5776
// * If only using Remote - Containers with a local container, uncomment this line instead:
5877
// "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ],
59-
6078
// Use 'postCreateCommand' to run commands after the container is created.
61-
// "postCreateCommand": "dotnet restore",
62-
79+
"postCreateCommand": "dotnet dev-certs https --trust",
6380
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
64-
"remoteUser": "vscode",
65-
"features": {
66-
"powershell": "latest"
67-
}
68-
}
81+
"remoteUser": "vscode"
82+
}

.github/workflows/main.yml

Lines changed: 68 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,86 @@ on:
1010
- main
1111

1212
jobs:
13-
build_and_deploy_job:
13+
build_only:
1414
if: (github.event_name == 'pull_request' && github.event.action != 'closed')
15-
runs-on: ubuntu-latest
16-
name: Build and Deploy Job
15+
runs-on: windows-latest
1716
steps:
1817
- uses: actions/checkout@v2
1918
with:
2019
submodules: true
21-
- name: Get PR title
22-
id: Pr-Title
23-
run: |
24-
title=$(gh pr view ${{ github.event.number }} --repo ${{ github.repository }} | head -n 1)
25-
echo "::set-output name=pr-title::$(echo $title)"
26-
shell: bash
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
continue-on-error: true
30-
- name: Setup .NET Core SDK
31-
uses: actions/[email protected]
32-
with:
33-
# Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x
34-
dotnet-version: |
35-
7.0.x
36-
6.0.x
37-
- name: Restore dependencies
38-
run: dotnet restore
39-
- name: Build
40-
run: dotnet build -c Release --no-restore
4120
- name: Publish Frontend
4221
run: dotnet publish -c Release ./src/CZ.Azure.FileExchange/ -o temp/frontend
4322
- name: Publish API
4423
run: dotnet publish -c Release ./src/CZ.Azure.FileExchange.Api/ -o temp/api --runtime win-x86 --no-self-contained
45-
- name: Deploy
46-
id: deploy
47-
run: './build/deploy.ps1 -Token ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_KINDDUNE004C2C103 }} -appBuildOutput ./temp/frontend/wwwroot/ -apiBuildOutput ./temp/api/ -envrionmentName ${{ github.event.number }} -pullrequestTitle "${{steps.Pr-Title.outputs.pr-title}}" -branchName ${{ github.head_ref }} -apiFramework "dotnetisolated" -apiFrameworkVersion "7.0" -Verbose'
24+
- name: zip outputs
4825
shell: pwsh
26+
run: |
27+
Compress-Archive temp/frontend/wwwroot/** temp/frontend.zip;
28+
Compress-Archive temp/api/** temp/api.zip;
29+
Remove-Item -Recurse -Force temp/frontend
30+
Remove-Item -Recurse -Force temp/api
31+
- name: Add Artifact App
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: artifact
35+
path: temp/
36+
- name: Add Artifact script
37+
uses: actions/upload-artifact@v3
38+
with:
39+
name: artifact
40+
path: ./build/deploy.ps1
41+
deploy_job:
42+
if: (github.event_name == 'pull_request' && github.event.action != 'closed')
43+
runs-on: ubuntu-latest
44+
needs:
45+
- build_only
46+
environment: 'Azure Infra'
47+
permissions:
48+
contents: read
49+
pages: write
50+
id-token: write
51+
pull-requests: write
52+
name: Deploy Job
53+
steps:
54+
- uses: actions/checkout@v2
55+
with:
56+
submodules: true
57+
- name: compile bicep
58+
uses: Azure/[email protected]
59+
with:
60+
bicepFilePath: pr.bicep
61+
outputFilePath: pr.json
62+
- name: Login to Azure
63+
uses: azure/login@v1
64+
with:
65+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
66+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
67+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
68+
enable-AzPSSession: true
69+
- name: Expose GitHub Runtime
70+
uses: crazy-max/ghaction-github-runtime@v2
71+
- name: "Deploy ARM template to Azure"
72+
uses: Azure/arm-deploy@v1
73+
with:
74+
scope: resourcegroup
75+
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
76+
resourceGroupName: 'pajetestfileshare2'
77+
region: 'West Europe'
78+
template: 'pr.json'
79+
parameters: name=pajetestfileshare2 githubToken=${{env.ACTIONS_RUNTIME_TOKEN}} branch=${{github.head_ref}} runId=${{github.run_id}} prNumber=${{github.event.number}} githubRuntimeApiUrl=${{env.ACTIONS_RUNTIME_URL}}
80+
deploymentMode: 'Incremental'
81+
- name: Get Website url
82+
uses: Azure/powershell@v1
83+
id: websiteUrl
84+
with:
85+
azPSVersion: 10.1.0
86+
inlineScript: |
87+
$hostname = (Get-AzStaticWebAppBuild -Name pajetestfileshare2 -ResourceGroupName pajetestfileshare2 -EnvironmentName ${{github.event.number}}).Hostname
88+
"hostname=https://$hostname" >> $env:GITHUB_OUTPUT
4989
- name: comment-pr
5090
uses: JoseThen/[email protected]
5191
with:
52-
comment: Your website can be viewed here '${{ steps.deploy.outputs.SiteUrl }}'
92+
comment: Your website can be viewed here '${{ steps.websiteUrl.outputs.hostname }}'
5393
# Github Token for authentication
5494
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5595
close_pull_request_job:
@@ -71,15 +111,4 @@ jobs:
71111
continue-on-error: true
72112
- name: Deploy
73113
run: './build/deploy.ps1 -Token ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_KINDDUNE004C2C103 }} -appBuildOutput ./temp/frontend/wwwroot/ -apiBuildOutput ./temp/api/ -envrionmentName ${{ github.event.number }} -pullrequestTitle "${{steps.Pr-Title.outputs.pr-title}}" -branchName ${{ github.head_ref }} -apiFramework "dotnetisolated" -apiFrameworkVersion "7.0" -Verbose -Delete'
74-
shell: pwsh
75-
compile_bicep:
76-
runs-on: 'ubuntu-latest'
77-
name: compile main bicep
78-
steps:
79-
- uses: actions/checkout@v2
80-
with:
81-
submodules: true
82-
- name: compile bicep
83-
uses: Azure/[email protected]
84-
with:
85-
bicepFilePath: main.bicep
114+
shell: pwsh

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
// these extensions are just recommended because they need subscribtion to work.
4+
// we don't want to force contributors to pay.
5+
"ms-dotnettools.csdevkit",
6+
"ms-dotnettools.vscodeintellicode-csharp"
7+
]
8+
}

.vscode/launch.json

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"name": "Launch and Debug Standalone Blazor WebAssembly App",
6-
"type": "blazorwasm",
7-
"request": "launch",
8-
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange"
9-
}
10-
]
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch and Debug Standalone Blazor WebAssembly App",
6+
"type": "blazorwasm",
7+
"request": "launch",
8+
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange"
9+
},
10+
{
11+
"name": "Attach to .NET Functions",
12+
"type": "coreclr",
13+
"request": "attach",
14+
"processId": "${command:azureFunctions.pickProcess}"
15+
}
16+
]
1117
}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"azureFunctions.projectSubpath": "src/CZ.Azure.FileExchange.Api",
3+
"azureFunctions.deploySubpath": "src/CZ.Azure.FileExchange.Api/bin/Release/net7.0/publish",
4+
"azureFunctions.projectLanguage": "C#",
5+
"azureFunctions.projectRuntime": "~4",
6+
"debug.internalConsoleOptions": "neverOpen",
7+
"azureFunctions.preDeployTask": "publish (functions)"
8+
}

0 commit comments

Comments
 (0)