How would I change the angular cli to version 12 when deploying a static site?

George Yang 20 Reputation points
2024-09-09T16:33:48.22+00:00

I am able to set node version to 14 but I'm not sure how to force global install to angular cli@12. Is there any way to do that in the Github Actions to Azure Static Site for Azure Static Web Apps CI/CD?

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,173 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sina Salam 22,031 Reputation points Volunteer Moderator
    2024-09-09T22:40:18.3966667+00:00

    Hello George Yang,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you would like to force change the angular cli to version 12 when deploying a static site.

    Yes, there is a way you can do this in your GitHub Actions workflow for deploying to Azure Static Web Apps, you will specify the installation command in your workflow YAML file by ensure the following:

    • The actions/setup-node@v2 action sets the Node.js version to 14.
    • The npm install -g @angular/cli@12 command installs Angular CLI version 12 globally.
    • The Azure/static-web-apps-deploy@v1 action deploys the built Angular project to Azure Static Web Apps.
    name: Deploy Angular App to Azure Static Web Apps
    on:
      push:
        branches:
          - main
    jobs:
      build_and_deploy:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout repository
            uses: actions/checkout@v2
          - name: Set up Node.js
            uses: actions/setup-node@v2
            with:
              node-version: '14'
          - name: Install Angular CLI globally
            run: npm install -g @angular/cli@12
          - name: Install dependencies
            run: npm install
          - name: Build Angular project
            run: npm run build --prod
          - name: Deploy to Azure Static Web Apps
            uses: Azure/static-web-apps-deploy@v1
            with:
              azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
              repo_token: ${{ secrets.GITHUB_TOKEN }}
              action: 'upload'
              app_location: '/'
              output_location: 'dist/your-angular-app'
    

    https://learn.microsoft.com/en-us/azure/static-web-apps/deploy-angular

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.