1

I have crossed check the syntax below and everything seem to be in order but it keeps failing, could someone please look through this syntax?

on:
  # Triggers the workflow on push or pull request events but only for the "main" branch
  push:
    branches: master

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checout code
        uses: actions/checkout@v2

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: ${{ env.DOTNET_VERSION }}

      - name: Set up dependency caching for faster builds
        uses: actions/cache@v2
        with:
          path: ~/.nuget/packages
          key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
          restore-keys: |
            ${{ runner.os }}-nuget-  

      - name: Build with dotnet
        run: dotnet build --configuration Release

      - name: Test
        run: dotnet test --no-restore --verbosity normal    

      - name: dotnet publish
        run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v3
        with:
          name: .net-app
          path: ${{env.DOTNET_ROOT}}/myapp

      - name: Login to Aure
        uses: azure/login@v1
        with:
            creds: ${{ secrets.AZURE_CREDENTIALS }}
            
      deploy:
        runs-on: ubuntu-latest
        needs: build
        environment:
          name: 'production'
          url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

        steps:
          - name: Download artifact from build job
            uses: actions/download-artifact@v3
            with:
              name: .net-app       
            
          - name: Deploy to Azure
            uses: azure/CLI@v1
            with:
              inlineScript: |
               ...
GuiFalourd
  • 15,523
  • 8
  • 44
  • 71
Jcide
  • 141
  • 1
  • 5
  • I would suggest you to use the [github action linter](https://github.com/rhysd/actionlint) to spot issue like this. See also the online version here https://rhysd.github.io/actionlint/ – Matteo Sep 05 '22 at 08:03

1 Answers1

0

The deploy job should be an item of the jobs table, you have wrong indentation try

on:
  # Triggers the workflow on push or pull request events but only for the "main" branch
  push:
    branches: master

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checout code
        uses: actions/checkout@v2

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: ${{ env.DOTNET_VERSION }}

      - name: Set up dependency caching for faster builds
        uses: actions/cache@v2
        with:
          path: ~/.nuget/packages
          key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
          restore-keys: |
            ${{ runner.os }}-nuget-  

      - name: Build with dotnet
        run: dotnet build --configuration Release

      - name: Test
        run: dotnet test --no-restore --verbosity normal    

      - name: dotnet publish
        run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v3
        with:
          name: .net-app
          path: ${{env.DOTNET_ROOT}}/myapp

      - name: Login to Aure
        uses: azure/login@v1
        with:
            creds: ${{ secrets.AZURE_CREDENTIALS }}
            
  deploy:
        runs-on: ubuntu-latest
        needs: build
        environment:
          name: 'production'
          url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

        steps:
          - name: Download artifact from build job
            uses: actions/download-artifact@v3
            with:
              name: .net-app       
            
          - name: Deploy to Azure
            uses: azure/CLI@v1
            with:
              inlineScript: |
               ...
Hamza AZIZ
  • 2,582
  • 1
  • 9
  • 18