From d448fe27797cc562083712b07cf1395405069e92 Mon Sep 17 00:00:00 2001 From: philspokas Date: Mon, 27 Nov 2023 22:02:34 -0800 Subject: [PATCH 1/6] initial test deploy --- .github/workflows/build-and-deploy-test.yml | 49 +++++++++++++++++++++ build/env/main.bicep | 26 +++++++++++ {tools => build/tools}/display-value.ps1 | 0 build/tools/scratch.ps1 | 5 +++ 4 files changed, 80 insertions(+) create mode 100644 .github/workflows/build-and-deploy-test.yml create mode 100644 build/env/main.bicep rename {tools => build/tools}/display-value.ps1 (100%) create mode 100644 build/tools/scratch.ps1 diff --git a/.github/workflows/build-and-deploy-test.yml b/.github/workflows/build-and-deploy-test.yml new file mode 100644 index 0000000..338fc17 --- /dev/null +++ b/.github/workflows/build-and-deploy-test.yml @@ -0,0 +1,49 @@ +name: JokeUI396 CI/CD + +on: + push: + branches: + - main + - 9-test-environment + workflow_dispatch: + +permissions: + id-token: write + contents: read + + +jobs: + build_and_deploy_job: + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v3 + - name: 'Login to Azure' + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID_CREATED_SP }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + - name: Get app key + id: appkey + run: | + $key=$(az staticwebapp secrets list --name JokeUi396-dev --query "properties.apiKey" -o tsv) + echo "key=$key" >> "$GITHUB_OUTPUT" + echo "test=apples" >> "$GITHUB_OUTPUT" + - name: Check Output + run: + echo "Key is $key and test is $apples" + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_ROCK_009A2F51E }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "/" # App source code path + api_location: ".output/server" # Api source code path - optional + output_location: ".output/public" # Built app content directory - optional + ###### End of Repository/Build Configurations ###### + diff --git a/build/env/main.bicep b/build/env/main.bicep new file mode 100644 index 0000000..6594e68 --- /dev/null +++ b/build/env/main.bicep @@ -0,0 +1,26 @@ +param location string = resourceGroup().location +param JokeUi396_sitename string = 'JokeUi396-dev' + +resource JokeUi396_site_resource 'Microsoft.Web/staticSites@2022-09-01' = { + name: JokeUi396_sitename + location: location + sku: { + name: 'Free' + tier: 'Free' + } + properties: { + repositoryUrl: 'https://github.com/IntelliTect-Samples/JokeUi396' + branch: 'main' + stagingEnvironmentPolicy: 'Enabled' + allowConfigFileUpdates: true + provider: 'GitHub' + enterpriseGradeCdnStatus: 'Disabled' + } +} + +// resource staticSites_JokeUi396_name_intellitectsamples_com 'Microsoft.Web/staticSites/customDomains@2022-09-01' = { +// parent:_JokeUi396_site_resource +// name: 'intellitectsamples.com' +// location: 'West US 2' +// properties: {} +// } diff --git a/tools/display-value.ps1 b/build/tools/display-value.ps1 similarity index 100% rename from tools/display-value.ps1 rename to build/tools/display-value.ps1 diff --git a/build/tools/scratch.ps1 b/build/tools/scratch.ps1 new file mode 100644 index 0000000..a1b2a15 --- /dev/null +++ b/build/tools/scratch.ps1 @@ -0,0 +1,5 @@ +az deployment group create --resource-group Joke-dev --template-file .\build\env\main.bicep + +$key = az staticwebapp secrets list --name JokeUi396-dev --query "properties.apiKey" -o tsv + +az staticwebapp show --name JokeUi396-dev --query "repositoryUrl" \ No newline at end of file From 7e3a2f76b21f9f30e8a27fd662ec2efe767a9568 Mon Sep 17 00:00:00 2001 From: philspokas Date: Mon, 27 Nov 2023 22:09:47 -0800 Subject: [PATCH 2/6] set env --- .github/workflows/build-and-deploy-test.yml | 1 + build/tools/scratch.ps1 | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/build-and-deploy-test.yml b/.github/workflows/build-and-deploy-test.yml index 338fc17..ceff42b 100644 --- a/.github/workflows/build-and-deploy-test.yml +++ b/.github/workflows/build-and-deploy-test.yml @@ -16,6 +16,7 @@ jobs: build_and_deploy_job: runs-on: ubuntu-latest name: Build and Deploy Job + environment: dev steps: - uses: actions/checkout@v3 - name: 'Login to Azure' diff --git a/build/tools/scratch.ps1 b/build/tools/scratch.ps1 index a1b2a15..9c5d5d5 100644 --- a/build/tools/scratch.ps1 +++ b/build/tools/scratch.ps1 @@ -1,3 +1,6 @@ +# https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/~/Credentials/appId/875a99e3-f3f2-4db4-8c51-f6ff26ee5b32/isMSAApp~/false + + az deployment group create --resource-group Joke-dev --template-file .\build\env\main.bicep $key = az staticwebapp secrets list --name JokeUi396-dev --query "properties.apiKey" -o tsv From 98a6601101bd349c483fde7c3c607a7bc6527d8f Mon Sep 17 00:00:00 2001 From: philspokas Date: Mon, 27 Nov 2023 22:12:41 -0800 Subject: [PATCH 3/6] fix var syntax --- .github/workflows/build-and-deploy-test.yml | 2 +- .github/workflows/deploy.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-test.yml b/.github/workflows/build-and-deploy-test.yml index ceff42b..acb5de3 100644 --- a/.github/workflows/build-and-deploy-test.yml +++ b/.github/workflows/build-and-deploy-test.yml @@ -28,7 +28,7 @@ jobs: - name: Get app key id: appkey run: | - $key=$(az staticwebapp secrets list --name JokeUi396-dev --query "properties.apiKey" -o tsv) + key=$(az staticwebapp secrets list --name JokeUi396-dev --query "properties.apiKey" -o tsv) echo "key=$key" >> "$GITHUB_OUTPUT" echo "test=apples" >> "$GITHUB_OUTPUT" - name: Check Output diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c1753dd..b8a873e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,6 +19,7 @@ jobs: - run: | ./display-value.ps1 ${{ secrets.ENVIRONMENTSECRET }} echo "deployment value is $env:deploymentvalue" + dir env: name: deploy shell: pwsh working-directory: tools From 57a55aba79df8bcc80d673d8a77fbfa18acb73fe Mon Sep 17 00:00:00 2001 From: philspokas Date: Mon, 27 Nov 2023 22:17:21 -0800 Subject: [PATCH 4/6] use env --- .github/workflows/build-and-deploy-test.yml | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-deploy-test.yml b/.github/workflows/build-and-deploy-test.yml index acb5de3..61c46c7 100644 --- a/.github/workflows/build-and-deploy-test.yml +++ b/.github/workflows/build-and-deploy-test.yml @@ -29,22 +29,22 @@ jobs: id: appkey run: | key=$(az staticwebapp secrets list --name JokeUi396-dev --query "properties.apiKey" -o tsv) - echo "key=$key" >> "$GITHUB_OUTPUT" - echo "test=apples" >> "$GITHUB_OUTPUT" + echo "key=$key" >> "$GITHUB_ENV" + echo "test=apples" >> "$GITHUB_ENV" - name: Check Output run: - echo "Key is $key and test is $apples" - - name: Build And Deploy - id: builddeploy - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_ROCK_009A2F51E }} - repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) - action: "upload" - ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### - # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - app_location: "/" # App source code path - api_location: ".output/server" # Api source code path - optional - output_location: ".output/public" # Built app content directory - optional - ###### End of Repository/Build Configurations ###### + echo "Key is $key and test is $apples" + # - name: Build And Deploy + # id: builddeploy + # uses: Azure/static-web-apps-deploy@v1 + # with: + # azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_ROCK_009A2F51E }} + # repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + # action: "upload" + # ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + # app_location: "/" # App source code path + # api_location: ".output/server" # Api source code path - optional + # output_location: ".output/public" # Built app content directory - optional + # ###### End of Repository/Build Configurations ###### From 3ce72dc5f14df5062d3cd618ee7eecbf0a970f97 Mon Sep 17 00:00:00 2001 From: philspokas Date: Mon, 27 Nov 2023 22:24:29 -0800 Subject: [PATCH 5/6] use key for deployment --- .github/workflows/build-and-deploy-test.yml | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-deploy-test.yml b/.github/workflows/build-and-deploy-test.yml index 61c46c7..0ea5e67 100644 --- a/.github/workflows/build-and-deploy-test.yml +++ b/.github/workflows/build-and-deploy-test.yml @@ -29,22 +29,22 @@ jobs: id: appkey run: | key=$(az staticwebapp secrets list --name JokeUi396-dev --query "properties.apiKey" -o tsv) - echo "key=$key" >> "$GITHUB_ENV" - echo "test=apples" >> "$GITHUB_ENV" + echo "key=$key" >> "$GITHUB_OUTPUT" + echo "test=apples" >> "$GITHUB_OUTPUT" - name: Check Output run: - echo "Key is $key and test is $apples" - # - name: Build And Deploy - # id: builddeploy - # uses: Azure/static-web-apps-deploy@v1 - # with: - # azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_ROCK_009A2F51E }} - # repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) - # action: "upload" - # ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### - # # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - # app_location: "/" # App source code path - # api_location: ".output/server" # Api source code path - optional - # output_location: ".output/public" # Built app content directory - optional - # ###### End of Repository/Build Configurations ###### + echo "Key is $key and test is $test" + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ steps.appkey.outputs.key }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "/" # App source code path + api_location: ".output/server" # Api source code path - optional + output_location: ".output/public" # Built app content directory - optional + ###### End of Repository/Build Configurations ###### From 08f6d5d85830748cdddb3829caaf05dc859a2c2d Mon Sep 17 00:00:00 2001 From: philspokas Date: Tue, 28 Nov 2023 05:40:42 -0800 Subject: [PATCH 6/6] clean up debug --- .github/workflows/build-and-deploy-test.yml | 4 ---- build/env/main.bicep | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-deploy-test.yml b/.github/workflows/build-and-deploy-test.yml index 0ea5e67..371c21e 100644 --- a/.github/workflows/build-and-deploy-test.yml +++ b/.github/workflows/build-and-deploy-test.yml @@ -30,10 +30,6 @@ jobs: run: | key=$(az staticwebapp secrets list --name JokeUi396-dev --query "properties.apiKey" -o tsv) echo "key=$key" >> "$GITHUB_OUTPUT" - echo "test=apples" >> "$GITHUB_OUTPUT" - - name: Check Output - run: - echo "Key is $key and test is $test" - name: Build And Deploy id: builddeploy uses: Azure/static-web-apps-deploy@v1 diff --git a/build/env/main.bicep b/build/env/main.bicep index 6594e68..63f6ef3 100644 --- a/build/env/main.bicep +++ b/build/env/main.bicep @@ -1,8 +1,8 @@ param location string = resourceGroup().location -param JokeUi396_sitename string = 'JokeUi396-dev' +param JokeSiteName string = 'JokeUi396-dev' resource JokeUi396_site_resource 'Microsoft.Web/staticSites@2022-09-01' = { - name: JokeUi396_sitename + name: JokeSiteName location: location sku: { name: 'Free' @@ -18,6 +18,18 @@ resource JokeUi396_site_resource 'Microsoft.Web/staticSites@2022-09-01' = { } } +// resource Joke_APIM_resource 'Microsoft.Web/staticSites/linkedBackends@2022-09-01' = { +// name: 'jokeapim' +// kind: 'API Management' +// parent: JokeUi396_site_resource +// properties: { +// backendResourceId: subscriptionResourceId('Microsoft.ApiManagement/service', 'jokeapim') +// region: location +// } +// } + +// '/subscriptions/a5045d8f-5a9a-4d29-aaee-1f829d64bee0/resourceGroups/jokefunction396/providers/Microsoft.ApiManagement/service/jokeapim' + // resource staticSites_JokeUi396_name_intellitectsamples_com 'Microsoft.Web/staticSites/customDomains@2022-09-01' = { // parent:_JokeUi396_site_resource // name: 'intellitectsamples.com'