0

Why doesn't "Workflow B" get triggered upon successful completion of "Workflow A" when a new file is pushed to branch_b?

I have three branches in my repository:

  • master (default branch)
  • branch_a
  • branch_b

In the branch_a branch, I've set up a workflow file that creates a file named "test2.txt" and then commits and pushes this file to the branch_b. Here's a snippet of the workflow file:

name: CD

on:
  push:
    branches:
      - branch_a

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

      - name: Create and push build branch
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          git config --global user.email "myemail"
          git config --global user.name "myusername"

          # Create a simple text file
          echo "This is a test file." > test2.txt

          # Commit and push changes to branch_b
          git fetch origin branch_b
          git checkout branch_b # Switch to branch_b
          git add test2.txt
          git commit -m "Add test file"
          git push origin branch_b

Additionally, I've created another workflow file on the branch_b branch:

name: Workflow B

on:
  push:
    branches:
      - branch_b

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


      - name: Output
        run: echo "Workflow on branch_b triggered"

However, despite successfully observing the "test2.txt" file being pushed to branch_b, the "Workflow B" doesn't seem to be triggered upon the completion of "Workflow A."

What could be the reasons for "Workflow B" not getting triggered as expected?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Atit Bimali
  • 45
  • 1
  • 7

0 Answers0