Revision-related push preventing required check in Pull Request

Hi all,

I am currently struggling with a workflow that I would like some help with.

My current workflow operates like this:
First the user pushes the code to GitHub, an Action script with pushes to branches other than main gets triggered and as part of its process, it versions the front- and back-end projects with pre-release versions. The workflow continues with linting, compiling, testing, etc., then when it’s all successful, it does a push so that the pre-release versions are on the branch.
This all works fine until I want to put down successful passes as requirements for PRs. What I end up with is a successful pass followed immediately by a version change push that doesn’t trigger any Actions. The PR only looks at the latest run and because it neither passed nor failed, the PR is blocked from being merged.

Here’s an example of what my PR’s commit history looks like:

I’d appreciate any help or ideas on how I can make this workflow work as it should.

Hi @jethas-bennettjones,

Glad to see you in Github Community Forum!

Could you please let me know how you do the version change? And if it doesn’t trigger any workflow, it should not be in the pull request check run list.

Is it possible to add the version change step into workflow and it will be treated as a workflow?

It’s recommened to share your repo or a sample repo here for further investigation.

Thanks

1 Like

Hi @weide-zhou,

The repo is private so I can’t share a link to it directly, but here is a sample workflow file:

name: Build (without versioning)
env:
  webapp_path: Project.WebApp

on:
  push:
    branches-ignore:
      - main

jobs:
  build-angular:
    runs-on: ubuntu-latest
    outputs:
      version: ${{steps.version.outputs.version}}
    steps:
      - uses: actions/checkout@v2

      - name: Setup NPM
        uses: actions/setup-node@v1
        with:
          node-version: "12"
          registry-url: "https://npm.pkg.github.com"

      - name: Get npm cache directory
        id: npm-cache
        run: |
          echo "::set-output name=dir::$(npm config get cache)"

      - name: Cache npm cache
        uses: actions/cache@v2
        with:
          path: ${{ steps.npm-cache.outputs.dir }}
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - name: Install npm packages
        working-directory: ./${{env.webapp_path}}/ClientApp
        run: npm ci
        env:
          NODE_AUTH_TOKEN: ${{secrets.PULL_NPM}}
          CYPRESS_INSTALL_BINARY: 0

      - name: Lint Angular app
        working-directory: ./${{env.webapp_path}}/ClientApp
        run: npm run lint

      - name: Bump Angular app version
        id: pre-version
        run: |
          echo "::set-output name=version::$(npm version prerelease)"
        working-directory: ./${{env.webapp_path}}/ClientApp

      - id: version
        run: |
          version=$(echo ${{steps.pre-version.outputs.version}} | cut -dv -f2)
          echo "::set-output name=version::$version"

      - name: Compile Angular app
        working-directory: ./${{env.webapp_path}}/ClientApp
        run: npm run build:ci --node-flags --max-old-space-size=7168 -- -c=test

      - name: Test Angular app
        uses: cypress-io/github-action@v2
        with:
          working-directory: ./${{env.webapp_path}}/ClientApp
          start: npx angular-http-server -g -p 4200 --path dist
          wait-on: "http://localhost:4200"

      - name: Publish Cypress Videos
        uses: actions/upload-artifact@v2
        if: always()
        with:
          name: Cypress Videos
          path: ${{env.webapp_path}}/ClientApp/cypress/videos/

      - name: Publish app
        uses: actions/upload-artifact@v2
        with:
          name: angular-app
          path: ./${{env.webapp_path}}/ClientApp/dist

  test-dotnet:
    runs-on: windows-latest
    env:
      DOTNET_NOLOGO: true
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-dotnet@v1
        with:
          dotnet-version: "3.1.x" # SDK Version to use; x will use the latest version of the 3.1 channel
          source-url: https://nuget.pkg.github.com/bennettjones/index.json
        env:
          NUGET_AUTH_TOKEN: ${{secrets.PULL_NPM}}

      - name: Setup NuGet
        uses: NuGet/setup-nuget@v1.0.2

      - name: Cache NUGET packages
        uses: actions/cache@v2
        with:
          path: ~/.nuget/packages
          key: ${{ runner.os }}-nuget-${{ hashFiles('**/${{env.webapp_path}}.Web.csproj')}}

      - name: Create node_modules folder # Needed so that the build process skips looking for "npm"
        working-directory: ./${{env.webapp_path}}/ClientApp
        run: New-Item -Type Directory -Name node_modules

      - name: Test App (Unit Tests)
        run: dotnet test --filter "FullyqualifiedName!~IntegrationTests"


      # - name: Test App (Integration)
      #   run: dotnet test --filter "FullyQualifiedName~IntegrationTests"

  package:
    needs: [build-angular, test-dotnet]
    runs-on: windows-latest
    env:
      DOTNET_NOLOGO: true

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-dotnet@v1
        with:
          dotnet-version: "3.1.x" # SDK Version to use; x will use the latest version of the 3.1 channel
          source-url: https://nuget.pkg.github.com/bennettjones/index.json
        env:
          NUGET_AUTH_TOKEN: ${{secrets.PULL_NPM}}

      - name: Setup NuGet
        uses: NuGet/setup-nuget@v1.0.2

      - name: Cache NUGET packages
        uses: actions/cache@v2
        with:
          path: ~/.nuget/packages
          key: ${{ runner.os }}-nuget-${{ hashFiles('**/${{env.webapp_path}}.Web.csproj')}}

      - name: Download Angular app
        uses: actions/download-artifact@v2
        with:
          name: angular-app
          path: ./${{env.webapp_path}}/ClientApp/dist

      - name: Bump Angular app version
        run: |
          npm version ${{needs.build-angular.outputs.version}}
        working-directory: ./${{env.webapp_path}}/ClientApp

      - name: Bump Dotnet Version
        run: |
          dotnet tool restore
          dotnet dotnet-version --project-file ./${{env.webapp_path}}/${{env.webapp_path}}.Web.csproj --skip-vcs ${{needs.build-angular.outputs.version}}

      - name: Commit Version change
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Uprev to ${{needs.build-angular.outputs.version}}

      - name: Publish App
        run: dotnet publish ./${{env.webapp_path}}/${{env.webapp_path}}.Web.csproj -c TEST -o ./publish

      - name: Create Artifact
        uses: actions/upload-artifact@v2
        with:
          path: ./publish

      - name: Zip Artifact
        id: zip-artifact
        run: |
          Compress-Archive -Path .\publish\* -DestinationPath artifact.zip

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{needs.build-angular.outputs.version}}
          release_name: Release ${{needs.build-angular.outputs.version}}

      - name: Upload Release Asset
        uses: actions/upload-release-asset@v1.0.2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ./artifact.zip
          asset_name: release-${{needs.build-angular.outputs.version}}.zip
          asset_content_type: application/zip

Hi @jethas-bennettjones,

Thanks for your reply!

I can repoduce the same on my pull request. This is due to action stefanzweifel/git-auto-commit-action@v4 will commit the changes together with message to repo, however, it used GITHUB_TOKEN by default which will not trigger new workflow. Hence, the new commit in the pull request will not have a status, which caused the pull request cannot be merged. It’s also mentioned in the action description here.

As a workaround, you can use another user who has write access to checkout the repository, and add job level if expression to check the github.actor, after the first push event workflow completed, aviod infinite workflow for the new commit.

It works on my side, my pull request here:https://github.com/weide-zhou/ticket13/pull/170

My workflow yaml for your reference:

Thanks

Hi @jethas-bennettjones,

Does it work for you? Let me know if you have any queries, thanks.

Hi @wiede-zhou,

Thanks for following up. After reviewing the full workflow in more depth, it seems like this will actually cause more problems then it’ll solve.

Thank you for the time you put into this, I sincerely appreciate it.