Create Environment based workflow on git to host angular application on Azure static web app

146 views Asked by At

I have created a workflow to host an Angular application on Azure static web apps but I want to host based on environment for development I want to execute command

ng build --configuration=development

and for production

ng build --configuration=production

What thing do I need to change in the following workflow?

name: angular prod CI/CD

on:
  workflow_dispatch:

jobs:
  build_and_deploy_job:
    #if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.secrets.AZURE_STATIC_XXXXX_Token  }}
          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: "" # Api source code path - optional
          output_location: "dist/" # Built app content directory - optional
          #app_build_command: "npm run-script ng build --configuration=production"
          #app_build_command: |
            #npm install --force
            #ng build --development --configuration=${{ steps.config.outputs.configuration }}
          ###### End of Repository/Build Configurations ######

  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_XXXXX_Token }}
          action: "close"
1

There are 1 answers

0
Florian Vuillemot On

GitHub actions seamlessly integrate environments which can reference specific secrets/env var.

You can also reuse action and pass the environment as an input. In your case, you may simply want to call a workflow based on an event.