Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actions not triggering even with Custom App #2461

Closed
Paddy-Farmeye opened this issue Oct 20, 2023 · 8 comments
Closed

Actions not triggering even with Custom App #2461

Paddy-Farmeye opened this issue Oct 20, 2023 · 8 comments

Comments

@Paddy-Farmeye
Copy link

Hi @peter-evans,

I'm aware of the original issue tracking the problem I'm having, and I've read your very good corresponding documentation. I've gone ahead and created a Github App and used it to provide a token ... however, I still can't seem to get actions to trigger.

My flow is as follows:

  • scheduled github action to create a PR with automerge enabled
  • when a PR is created two actions should occur (mergeable check, and build/test)
Screenshot 2023-10-20 at 11 45 01

The PR gets created with automerge enabled as expected.
The mergeable check also runs as expected ... but the build_and_test never kicks off.

I feel I've probably just missed something small and was hoping someone could just cast their eye over my config.

My config

Automerge PR config

name: Release
on:
  # update the main branch at 8pm (UTC)
  schedule:
    - cron: '0 20 * * 1-4'
  # or update the main branch manually
  workflow_dispatch:

jobs:
  createPullRequest:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout 🛎
        uses: actions/checkout@v4
        with:
          ref: main
          fetch-tags: true
          fetch-depth: 0

      - name: Fetch new tag version
        run: |
          git fetch --tags --prune --prune-tags
          VERSION=`git tag --sort=-creatordate | head -1`
          echo "Version ${VERSION}"

          #replace . with space so can split into an array
          VERSION_BITS=(${VERSION//./ })

          VNUM1=${VERSION_BITS[0]}
          VNUM2=${VERSION_BITS[1]}
          VNUM3=${VERSION_BITS[2]}
          VNUM3=$((VNUM3+1))

          #create new tag
          NEW_TAG="$VNUM1.$VNUM2.$VNUM3"

          echo "New Version ${NEW_TAG}"
          echo "version=${NEW_TAG}" >> $GITHUB_OUTPUT
          id: fetch-tag-version

      - name: Fetch Token
        uses: tibdex/github-app-token@v1
        id: generate-token
        with:
          app_id: ${{ secrets.TOKEN_APP_ID }}
          private_key: ${{ secrets.TOKEN_PRIVATE_KEY }}

      - name: Update main branch
        run: |
          git reset --hard origin/devel

      - name: Create Pull Request
        id: cpr
        uses: peter-evans/create-pull-request@v5
        with:
          token: ${{ steps.generate-token.outputs.token }}
          commit-message: Release ${{ steps.fetch-tag-version.outputs.version }}
          committer: GitHub <[email protected]>
          author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
          signoff: false
          branch: release
          base: main
          delete-branch: true
          title: Release ${{ steps.fetch-tag-version.outputs.version }}
          body: Release ${{ steps.fetch-tag-version.outputs.version }}
          draft: false

      - name: Pull Request Automerge
        if: steps.cpr.outputs.pull-request-operation == 'created'
        uses: peter-evans/enable-pull-request-automerge@v3
        with:
          pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
          merge-method: merge

build_and_test config

name: PR build Checks

on:
 pull_request:
    branches:
      - devel
      - release

jobs:
  build_and_test:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 11

    - name: Cache the Maven packages to speed up build
      uses: actions/cache@v1
      with:
        path: ~/.m2
        key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
        restore-keys: ${{ runner.os }}-m2     
  
    - name: Build and test project with Maven
      run: mvn -B package --file pom.xml

Sorry for the inconvenience, hopefully it's something small I've overlooked.
Thank you

@Paddy-Farmeye
Copy link
Author

As you suggested I have set the following permissions on my Github App:

Under Repository permissions: Contents select Access: Read & write.
Under Repository permissions: Pull requests select Access: Read & write.
Under Organization permissions: Members select Access: Read-only.

But I'm wondering if under Repository, do I also need to set values for Actions and/or Checks and/or Commit statuses?, ref:
Screenshot 2023-10-20 at 12 07 09
Screenshot 2023-10-20 at 12 09 31
Screenshot 2023-10-20 at 12 09 51

@peter-evans
Copy link
Owner

Hi @Paddy-Farmeye

It looks like the permissions are correct on the app. Is the app installed on the repository where the workflow is running?

Please could you show me a larger screenshot of the PR in GitHub so I can see other details, or a link to it if it's public.

@Paddy-Farmeye
Copy link
Author

Paddy-Farmeye commented Oct 20, 2023

Hi @peter-evans Yes, the app is installed and runs in the action.
Screenshot 2023-10-20 at 12 20 11

A larger screenshot of the PR:
Screenshot 2023-10-20 at 12 29 27

@peter-evans
Copy link
Owner

Ah, I see the problem. The pull request workflow is not triggering because the branches you specified are not the target of the PR. It's the target branch, not the PR branch that you need to specify here:

on:
 pull_request:
    branches:
-     - devel
-     - release
+     - main

@Paddy-Farmeye
Copy link
Author

Ah okay, let me give this a go and if all's good I'll close this issue, thanks.

@Paddy-Farmeye
Copy link
Author

@peter-evans thunderbirds are go ... thanks for your time and prompt resolution.

@lcarva
Copy link

lcarva commented Sep 24, 2024

I'm ashamed to admit that I just ran into the same issue. Would you be willing to accept a doc change to warn future users about this pitfall?

@peter-evans
Copy link
Owner

I'm ashamed to admit that I just ran into the same issue. Would you be willing to accept a doc change to warn future users about this pitfall?

I'm really not sure where that would go in the docs. It's more of a general GitHub Actions usage issue, not really anything specific to this action. So I'll keep an eye out, and if lots of users encounter this then I might consider adding something to the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants