From 7b240d2d3e1537688410b561bb4c908c0de6e3a4 Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Wed, 6 Sep 2023 00:32:57 +0530 Subject: [PATCH 01/11] Create DeploymentToAKS.yml --- .github/workflows/DeploymentToAKS.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/DeploymentToAKS.yml diff --git a/.github/workflows/DeploymentToAKS.yml b/.github/workflows/DeploymentToAKS.yml new file mode 100644 index 0000000..45e89f2 --- /dev/null +++ b/.github/workflows/DeploymentToAKS.yml @@ -0,0 +1,23 @@ +name: Run Azure Login with OpenID Connect +on: [push] + +permissions: + id-token: write + contents: read + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: 'Az CLI login' + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: 'Run Azure CLI commands' + run: | + az account show + az group list + pwd From 6caf02ac8af708e9faee11eb4febf5263e296cc3 Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Wed, 6 Sep 2023 00:55:16 +0530 Subject: [PATCH 02/11] Update DeploymentToAKS.yml --- .github/workflows/DeploymentToAKS.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/DeploymentToAKS.yml b/.github/workflows/DeploymentToAKS.yml index 45e89f2..50c9d88 100644 --- a/.github/workflows/DeploymentToAKS.yml +++ b/.github/workflows/DeploymentToAKS.yml @@ -9,6 +9,14 @@ jobs: build-and-deploy: runs-on: ubuntu-latest steps: + - name: Install Azure cli + run: | + sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg + curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null + AZ_REPO=$(lsb_release -cs) + echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list + sudo apt-get update + sudo apt-get install azure-cli - name: 'Az CLI login' uses: azure/login@v1 with: From beb04b53731825936c6693e3c4893cbf32253732 Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Wed, 6 Sep 2023 01:33:44 +0530 Subject: [PATCH 03/11] Update DeploymentToAKS.yml --- .github/workflows/DeploymentToAKS.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/DeploymentToAKS.yml b/.github/workflows/DeploymentToAKS.yml index 50c9d88..45e89f2 100644 --- a/.github/workflows/DeploymentToAKS.yml +++ b/.github/workflows/DeploymentToAKS.yml @@ -9,14 +9,6 @@ jobs: build-and-deploy: runs-on: ubuntu-latest steps: - - name: Install Azure cli - run: | - sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg - curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null - AZ_REPO=$(lsb_release -cs) - echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list - sudo apt-get update - sudo apt-get install azure-cli - name: 'Az CLI login' uses: azure/login@v1 with: From 0863489d516617e174ba76ed39babffd507e9ec0 Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Wed, 6 Sep 2023 01:46:40 +0530 Subject: [PATCH 04/11] Update DeploymentToAKS.yml --- .github/workflows/DeploymentToAKS.yml | 31 +++++++++++---------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/.github/workflows/DeploymentToAKS.yml b/.github/workflows/DeploymentToAKS.yml index 45e89f2..4b5a719 100644 --- a/.github/workflows/DeploymentToAKS.yml +++ b/.github/workflows/DeploymentToAKS.yml @@ -1,23 +1,18 @@ -name: Run Azure Login with OpenID Connect on: [push] -permissions: - id-token: write - contents: read - -jobs: +name: AzureLoginSample + +jobs: build-and-deploy: runs-on: ubuntu-latest steps: - - name: 'Az CLI login' - uses: azure/login@v1 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - - - name: 'Run Azure CLI commands' - run: | - az account show - az group list - pwd + - name: Log in with Azure + uses: azure/login@v1 + with: + creds: '${{ secrets.AZURE_CREDENTIALS }}' + enable-AzPSSession: true + - name: Azure PowerShell Action + uses: Azure/powershell@v1 + with: + inlineScript: Get-AzResourceGroup -Name "< YOUR RESOURCE GROUP >" + azPSVersion: "latest" From 5c6f63015dc532f551b44bc0c1cbe3ceb2c84b0f Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Wed, 6 Sep 2023 01:49:36 +0530 Subject: [PATCH 05/11] Update DeploymentToAKS.yml --- .github/workflows/DeploymentToAKS.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/DeploymentToAKS.yml b/.github/workflows/DeploymentToAKS.yml index 4b5a719..6e8ab59 100644 --- a/.github/workflows/DeploymentToAKS.yml +++ b/.github/workflows/DeploymentToAKS.yml @@ -14,5 +14,5 @@ jobs: - name: Azure PowerShell Action uses: Azure/powershell@v1 with: - inlineScript: Get-AzResourceGroup -Name "< YOUR RESOURCE GROUP >" + inlineScript: Get-AzResourceGroup -Name "AZ_RG" azPSVersion: "latest" From a189eb660d73b68c942e59bae2877c343c34a9c1 Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Wed, 6 Sep 2023 02:06:34 +0530 Subject: [PATCH 06/11] Update DeploymentToAKS.yml --- .github/workflows/DeploymentToAKS.yml | 47 +++++++++++++++++---------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/.github/workflows/DeploymentToAKS.yml b/.github/workflows/DeploymentToAKS.yml index 6e8ab59..ba9b283 100644 --- a/.github/workflows/DeploymentToAKS.yml +++ b/.github/workflows/DeploymentToAKS.yml @@ -1,18 +1,31 @@ -on: [push] - -name: AzureLoginSample - +name: Deployment +"on": + push: + branches: + - master + workflow_dispatch: {} +env: + ACR_RESOURCE_GROUP: AZ_RG + AZURE_CONTAINER_REGISTRY: bgswacr + CLUSTER_NAME: bgswaks + CLUSTER_RESOURCE_GROUP: AZ_RG + CONTAINER_NAME: image-workflow-1693495803035 + DEPLOYMENT_MANIFEST_PATH: | + manifests/deployment.yaml + manifests/service.yaml jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Log in with Azure - uses: azure/login@v1 - with: - creds: '${{ secrets.AZURE_CREDENTIALS }}' - enable-AzPSSession: true - - name: Azure PowerShell Action - uses: Azure/powershell@v1 - with: - inlineScript: Get-AzResourceGroup -Name "AZ_RG" - azPSVersion: "latest" + buildImage: + permissions: + contents: read + id-token: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: azure/login@v1 + name: Azure login + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + - name: Build and push image to ACR + run: az acr build --image ${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.ACR_RESOURCE_GROUP }} -f Dockerfile ./ From 615893b2a889733ef417f60f20648e929c9c4ffa Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Wed, 6 Sep 2023 13:16:53 +0530 Subject: [PATCH 07/11] Create pull-request.yaml --- .github/workflows/pull-request.yaml | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/pull-request.yaml diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml new file mode 100644 index 0000000..0c5a402 --- /dev/null +++ b/.github/workflows/pull-request.yaml @@ -0,0 +1,48 @@ +name: Pull Request Example + +on: + pull_request: + branches: + - main + paths: + - typescript-project/** + workflow_dispatch: + +jobs: + pull-request: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: typescript-project + + steps: + - uses: actions/checkout@v2 + + # Setup Nodejs + - name: Setup Node.js 16 + uses: actions/setup-node@v2 + with: + node-version: "16.x" + cache: 'npm' + cache-dependency-path: typescript-project/yarn.lock + + # Install Yarn + - name: Install Yarn + run: npm install --global yarn + + # Install libraries + - name: Install dependencies + run: yarn install --frozen-lockfile + + # Run linting + - name: Run linting + run: yarn lint + + # Compile the code + - name: Build project + run: yarn build + + # Run tests + - name: Run tests + run: yarn test From dbae9d912e58625ada81b03065f6c7a46cfbd5dc Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Wed, 6 Sep 2023 13:17:50 +0530 Subject: [PATCH 08/11] Update Dockerfile --- my-app/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/my-app/Dockerfile b/my-app/Dockerfile index e69de29..56f3b36 100644 --- a/my-app/Dockerfile +++ b/my-app/Dockerfile @@ -0,0 +1 @@ + From ea14103c88722a2679378fd76576b2e3c5958480 Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Wed, 6 Sep 2023 13:26:32 +0530 Subject: [PATCH 09/11] Update DeploymentToAKS.yml --- .github/workflows/DeploymentToAKS.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/DeploymentToAKS.yml b/.github/workflows/DeploymentToAKS.yml index ba9b283..62adbf5 100644 --- a/.github/workflows/DeploymentToAKS.yml +++ b/.github/workflows/DeploymentToAKS.yml @@ -3,6 +3,8 @@ name: Deployment push: branches: - master + paths: + - tic-tac-toe-project/** workflow_dispatch: {} env: ACR_RESOURCE_GROUP: AZ_RG From e9f7876dbac1cdbefbfcddd959bf6b99d7cf9403 Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Wed, 6 Sep 2023 13:31:15 +0530 Subject: [PATCH 10/11] Update DeploymentToAKS.yml --- .github/workflows/DeploymentToAKS.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/DeploymentToAKS.yml b/.github/workflows/DeploymentToAKS.yml index 62adbf5..496e724 100644 --- a/.github/workflows/DeploymentToAKS.yml +++ b/.github/workflows/DeploymentToAKS.yml @@ -4,7 +4,7 @@ name: Deployment branches: - master paths: - - tic-tac-toe-project/** + - my-app/** workflow_dispatch: {} env: ACR_RESOURCE_GROUP: AZ_RG From 25ab25266cf8ad82180028b47f0611ae29d4d322 Mon Sep 17 00:00:00 2001 From: PDJ5KOR <143378950+PDJ5KOR@users.noreply.github.com> Date: Thu, 7 Sep 2023 12:11:10 +0530 Subject: [PATCH 11/11] Create CICD.yml --- .github/workflows/CICD.yml | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/CICD.yml diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml new file mode 100644 index 0000000..18182f4 --- /dev/null +++ b/.github/workflows/CICD.yml @@ -0,0 +1,53 @@ +name: CI + CD + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + Build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Compile + run: echo Hello, world! + + DeployDev: + name: Deploy to Dev + if: github.event_name == 'pull_request' + needs: [Build] + runs-on: ubuntu-latest + environment: + name: Development + url: 'http://dev.myapp.com' + steps: + - name: Deploy + run: echo I am deploying! + + DeployStaging: + name: Deploy to Staging + if: github.event.ref == 'refs/heads/main' + needs: [Build] + runs-on: ubuntu-latest + environment: + name: Staging + url: 'http://test.myapp.com' + steps: + - name: Deploy + run: echo I am deploying! + + DeployProd: + name: Deploy to Production + needs: [DeployStaging] + runs-on: ubuntu-latest + environment: + name: Production + url: 'http://www.myapp.com' + steps: + - name: Deploy + run: echo I am deploying! +