Merge by github action does not trigger CI that listen by branch

Viewed 318

I had two github action, one of merge-staging-in-to-master, the other one is CI. The merge-staging-in-to-master was triggered by manually. And CI was triggered by push to master. But, when I triggered the merge-staging-in-to-master manually, the CI does nothing...

The expectation I want is invoke the CI action after merge-staging-in-to-master was done. There is my code below.

merge-staging-in-to-master.yml

# This is a basic workflow to help you get started with Actions

name: merge-staging-to-master

# Controls when the workflow will run
on:
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:
  # Allows external webhook trigger
  repository_dispatch:
    types:
      - merge-staging-to-master

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  merge-staging-to-master:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Runs a set of commands using the runners shell
      - name: Run a multi-line script
        run: |
          git fetch origin --unshallow
          git checkout -t remotes/origin/master
          git pull origin master
          git config --global user.name "user"
          git config --global user.email "user@mail.com"
          git merge staging -m "[AUTO] merge staging back to master"
          git push

CI.yml

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-18.04

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '14'
      - id: 'auth'
        name: 'Authenticate to Google Cloud'
        uses: 'google-github-actions/auth@v0'
        with:
          credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'
      - name: Install Dependencies
        run: |
          sudo apt update
          sudo apt install -y libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev librsvg2-dev 

      - name: 'Set up Cloud SDK'
        uses: 'google-github-actions/setup-gcloud@v0'

      - name: Build 
        run: sudo npm install --build-from-source && npx prisma generate dev && npm run build 

      - name: Deploy
        run: npm run deploy   
1 Answers

This is a builtin feature of GitHub actions to prevent jobs from triggering more jobs and potentially burning through your action minutes in a very short time (all the while blocking hosted runners for others as well).

The GitHub actions tokens used to authenticate have a special flag on them by which GitHub knows the token is from an Actions workflow.

If you know what you're doing you can use a PAT or Oauth App token to authenticate your git push instead, that will trigger further workflows. If you search the GitHub marketplace you'll find a few actions that can retrieve an OAuth App token.

Related