diff --git a/.github/workflows/spinup-destroy.yml b/.github/workflows/spinup-destroy.yml new file mode 100644 index 0000000..a7e7aed --- /dev/null +++ b/.github/workflows/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: larsbj-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 diff --git a/package-lock.json b/package-lock.json index f6db4a9..a53cb2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6077,10 +6077,9 @@ } }, "node-forge": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.9.0.tgz", - "integrity": "sha512-7ASaDa3pD+lJ3WvXFsxekJQelBKRpne+GOVbLbtHYdd7pFspyeuJHnWfLplGf3SwKGbfs/aYl5V/JCIaHVUKKQ==", - "dev": true + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", + "integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==" }, "node-int64": { "version": "0.4.0", @@ -7535,6 +7534,14 @@ "dev": true, "requires": { "node-forge": "0.9.0" + }, + "dependencies": { + "node-forge": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.9.0.tgz", + "integrity": "sha512-7ASaDa3pD+lJ3WvXFsxekJQelBKRpne+GOVbLbtHYdd7pFspyeuJHnWfLplGf3SwKGbfs/aYl5V/JCIaHVUKKQ==", + "dev": true + } } }, "semver": { diff --git a/package.json b/package.json index 1fc1417..1abe7ba 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "webpack-dev-server": "^3.11.0" }, "dependencies": { - "kind-of": "^6.0.3" + "kind-of": "^6.0.3", + "node-forge": "^0.10.0" } }