From 71862f64f7471671f7c4272aa3ed61009e86fa6c Mon Sep 17 00:00:00 2001 From: Hector Alfaro Date: Mon, 10 Feb 2020 07:03:26 -0500 Subject: [PATCH 1/4] add Azure configuration workflows --- .github/CHANGETHIS/spinup-destroy.yml | 72 +++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/CHANGETHIS/spinup-destroy.yml diff --git a/.github/CHANGETHIS/spinup-destroy.yml b/.github/CHANGETHIS/spinup-destroy.yml new file mode 100644 index 0000000..4c84a54 --- /dev/null +++ b/.github/CHANGETHIS/spinup-destroy.yml @@ -0,0 +1,72 @@ +name: Configure Azure environment + +on: + pull_request: + types: [labeled] + +env: + PACKAGES_TOKEN: ${{secrets.PACKAGES_TOKEN}} + AZURE_RESOURCE_GROUP: cd-with-actions + AZURE_APP_PLAN: actions-ttt-deployment + AZURE_LOCATION: '"Central US"' + ################################################# + ### USER PROVIDED VALUES ARE REQUIRED BELOW ### + ################################################# + ################################################# + ### REPLACE USERNAME WITH GH USERNAME ### + AZURE_WEBAPP_NAME: USERNAME-ttt-app + ################################################# + +jobs: + setup-up-azure-resources: + runs-on: ubuntu-latest + + if: contains(github.event.pull_request.labels.*.name, 'spin up environment') + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Azure login + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Create Azure resource group + if: success() + run: | + az group create --location ${{env.AZURE_LOCATION}} --name ${{env.AZURE_RESOURCE_GROUP}} --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} + + - name: Create Azure app service plan + if: success() + run: | + az appservice plan create --resource-group ${{env.AZURE_RESOURCE_GROUP}} --name ${{env.AZURE_APP_PLAN}} --is-linux --sku F1 --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} + + - name: Create webapp resource + if: success() + run: | + az webapp create --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --plan ${{ env.AZURE_APP_PLAN }} --name ${{ env.AZURE_WEBAPP_NAME }} --deployment-container-image-name nginx --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} + + - name: Configure webapp to use GitHub Packages + if: success() + run: | + az webapp config container set --docker-custom-image-name nginx --docker-registry-server-password ${{secrets.GITHUB_TOKEN}} --docker-registry-server-url https://docker.pkg.github.com --docker-registry-server-user ${{github.actor}} --name ${{ env.AZURE_WEBAPP_NAME }} --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} + + destroy-azure-resources: + runs-on: ubuntu-latest + + if: contains(github.event.pull_request.labels.*.name, 'destroy environment') + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Azure login + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Destroy Azure environment + if: success() + run: | + az group delete --name ${{env.AZURE_RESOURCE_GROUP}} --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} --yes \ No newline at end of file From 017695d66d7244e2ecdaebd9033b43e63676b007 Mon Sep 17 00:00:00 2001 From: Stuart Eggerton Date: Wed, 13 May 2020 22:32:09 +1000 Subject: [PATCH 2/4] Rename .github/CHANGETHIS/spinup-destroy.yml to .github/workflows/spinup-destroy.yml --- .github/{CHANGETHIS => workflows}/spinup-destroy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/{CHANGETHIS => workflows}/spinup-destroy.yml (97%) diff --git a/.github/CHANGETHIS/spinup-destroy.yml b/.github/workflows/spinup-destroy.yml similarity index 97% rename from .github/CHANGETHIS/spinup-destroy.yml rename to .github/workflows/spinup-destroy.yml index 4c84a54..9740a90 100644 --- a/.github/CHANGETHIS/spinup-destroy.yml +++ b/.github/workflows/spinup-destroy.yml @@ -69,4 +69,4 @@ jobs: - name: Destroy Azure environment if: success() run: | - az group delete --name ${{env.AZURE_RESOURCE_GROUP}} --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} --yes \ No newline at end of file + az group delete --name ${{env.AZURE_RESOURCE_GROUP}} --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} --yes From cdced1f154e85c01ccbb59677438e2af3ff5fbe2 Mon Sep 17 00:00:00 2001 From: Stuart Eggerton Date: Wed, 13 May 2020 22:33:26 +1000 Subject: [PATCH 3/4] Update spinup-destroy.yml --- .github/workflows/spinup-destroy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spinup-destroy.yml b/.github/workflows/spinup-destroy.yml index 9740a90..0ec5a22 100644 --- a/.github/workflows/spinup-destroy.yml +++ b/.github/workflows/spinup-destroy.yml @@ -14,7 +14,7 @@ env: ################################################# ################################################# ### REPLACE USERNAME WITH GH USERNAME ### - AZURE_WEBAPP_NAME: USERNAME-ttt-app + AZURE_WEBAPP_NAME: gitstua-ttt-app ################################################# jobs: From 41c6d8551fa22803232b53ab5d1b42d244e46b8f Mon Sep 17 00:00:00 2001 From: Stuart Eggerton Date: Wed, 13 May 2020 22:59:07 +1000 Subject: [PATCH 4/4] Update spinup-destroy.yml --- .github/workflows/spinup-destroy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spinup-destroy.yml b/.github/workflows/spinup-destroy.yml index 0ec5a22..2a51b57 100644 --- a/.github/workflows/spinup-destroy.yml +++ b/.github/workflows/spinup-destroy.yml @@ -40,7 +40,7 @@ jobs: - name: Create Azure app service plan if: success() run: | - az appservice plan create --resource-group ${{env.AZURE_RESOURCE_GROUP}} --name ${{env.AZURE_APP_PLAN}} --is-linux --sku F1 --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} + az appservice plan create --resource-group ${{env.AZURE_RESOURCE_GROUP}} --name ${{env.AZURE_APP_PLAN}} --is-linux --sku B1 --subscription ${{secrets.AZURE_SUBSCRIPTION_ID}} - name: Create webapp resource if: success()