peter-evans / create-pull-request

A GitHub action to create a pull request for changes to your repository in the actions workspace
MIT License
2.08k stars 408 forks source link

Changes from test folder doesn't added to the PR #2931

Closed Poornachand200 closed 2 months ago

Poornachand200 commented 3 months ago

Changes from test folder doesn't added to the PR

Describe your issue here.

Creating pull request from test2 branch to main branch I have the changes in test folder which is copied to production folder recursively in one step and pull request created in the next step I am expecting changes in both test and production to get added to the PR . But it is considering only production folder changes in the PR being created.

Steps to reproduce

If this issue is describing a possible bug please provide (or link to) your GitHub Actions workflow.

Attached the log file of the job https://github.com/nuuday/ciam-server-profiles/actions/runs/9300256169 logs_24340228060 (1).zip


name: "Start Promotion Staging->Production"

permissions:
  contents: write
  issues: write
  pull-requests: write

on:
  workflow_call: 
    inputs:
      product:
        description: 'ping product to promote'
        required: true
        type: string
      branch:
        description: 'branch to deploy'
        required: true
        type: string

jobs:
  promote:
    runs-on: ubuntu-latest
    name: Promoting from test to production
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ inputs.branch }}
          fetch-depth: 0

      - name: Copy PingDirectory
        if: inputs.product == 'pingdirectory'
        run: |
          rm -rf ./nuuday-ciam/production/pingdirectory
          cp -r nuuday-ciam/test/pingdirectory/ nuuday-ciam/production/pingdirectory
          find ./nuuday-ciam/production/pingdirectory/ -name '*_test.*' -type f -delete

      - name: Copy PingFederate
        if: inputs.product == 'pingfederate'
        run: |
          npm install --dev --prefix .build
          rm -rf nuuday-ciam/production/pingfederate
          cp -r nuuday-ciam/test/pingfederate nuuday-ciam/production/pingfederate
          find ./nuuday-ciam/production/pingfederate/ -name '*.css.map*' -type f -delete
          npm run config:production --prefix .build

      - name: Git status
        run: git status

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v6
        with:
          token: ${{ secrets.REPOSITORY_ROBOT_PAT }}
          branch: "release/${{inputs.product}}-test-to-production"
          commit-message: "chore(release): promoting ${{inputs.product}} from test to production"
          title: "chore(release): promoting ${{inputs.product}} from test to production"
          assignees: ${{ github.actor }}
          base: main
          labels: "automated promotion"
          branch-suffix: short-commit-hash
          body: |
            THIS IS AN AUTOMATED PROMOTION FROM THE TEST ENVIRONMENT TO PRODUCTION ENVIRONMENT.

            PLEASE REVIEW THE FILE CHANGES IN THIS PR AND MERGE IT WHEN YOU ARE READY.

            WHEN THIS PR IS MERGED, THE CHANGES WILL BE AUTOMATICALLY DEPLOYED TO PRODUCTION.
Poornachand200 commented 3 months ago

@peter-evans Could you please help me here

Poornachand200 commented 3 months ago

@peter-evans Its a blocker for the current development. Could you please assist me?

peter-evans commented 3 months ago

Hi @Poornachand200

It's not clear to me what you are trying to do. Are you trying to make a pull request from an existing branch to main without any changes?

The standard pattern for using this action is to checkout the target branch (main) and then create the changes you want on top of that branch. So I think your workflow is a bit confusing, because your checking out the "branch to deploy" and then setting the base input to main. All this will do is take the changes you are making in the workflow and try to rebase them on main. It's not raising a PR with changes that already exist in the branch input of the workflow.

Poornachand200 commented 3 months ago

@peter-evans Yes, I am trying to promote the changes from branch i.e test2 to main based on different inputs. I altered the workflow as below by referring to your documentation. I would like to create 2 pull requests for two different products pingfederate and pingdirectory. I copy the changes accordingly in git copy command based on the inputs from test folder to production folder as mentioned below. But the 2 pull requests has the changes from both the folders pingfederate and pingdirectory. Below are the expected changes in the pull requests. I can provide you more information.

Condition:

i) If the input is pingdirectory

The pull request created from test2 to main should have only the changes from below path.

nuuday-ciam/test/pingdirectory/ nuuday-ciam/production/pingdirectory/ - changes copied from nuuday-ciam/test/pingdirectory/

ii) If the input is pingfederate

The pull request created from test2 to main should have only the changes from below path.

nuuday-ciam/test/pingfederate/ nuuday-ciam/production/pingfederate/ - changes copied from nuuday-ciam/test/pingfederate/


name: "Start Promotion Staging->Production"

permissions:
  contents: write
  issues: write
  pull-requests: write

on:
  workflow_call: 
    inputs:
      product:
        description: 'ping product to promote'
        required: true
        type: string
      branch:
        description: 'branch to deploy'
        required: true
        type: string

jobs:
  promote:
    runs-on: ubuntu-latest
    name: Promoting from test to production
    steps:
      - uses: actions/checkout@v4
        with:
          ref: main
          fetch-depth: 0

      - name: Reset promotion branch
        run: |
          git fetch origin ${{ inputs.branch }}:${{ inputs.branch }}
          git reset --hard ${{ inputs.branch }}

      - name: Copy PingDirectory
        if: inputs.product == 'pingdirectory'
        run: |
          rm -rf ./nuuday-ciam/production/pingdirectory
          cp -r nuuday-ciam/test/pingdirectory/ nuuday-ciam/production/pingdirectory
          find ./nuuday-ciam/production/pingdirectory/ -name '*_test.*' -type f -delete

      - name: Copy PingFederate
        if: inputs.product == 'pingfederate'
        run: |
          npm install --dev --prefix .build
          rm -rf nuuday-ciam/production/pingfederate
          cp -r nuuday-ciam/test/pingfederate nuuday-ciam/production/pingfederate
          find ./nuuday-ciam/production/pingfederate/ -name '*.css.map*' -type f -delete
          npm run config:production --prefix .build

      - name: Git status
        run: git status

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v6
        with:
          token: ${{ secrets.REPOSITORY_ROBOT_PAT }}
          branch: "release/${{inputs.product}}-test-to-production"
          commit-message: "chore(release): promoting ${{inputs.product}} from test to production"
          title: "chore(release): promoting ${{inputs.product}} from test to production"
          assignees: ${{ github.actor }}
          labels: "automated promotion"
          branch-suffix: short-commit-hash
          body: |
            THIS IS AN AUTOMATED PROMOTION FROM THE TEST ENVIRONMENT TO PRODUCTION ENVIRONMENT.

            PLEASE REVIEW THE FILE CHANGES IN THIS PR AND MERGE IT WHEN YOU ARE READY.

            WHEN THIS PR IS MERGED, THE CHANGES WILL BE AUTOMATICALLY DEPLOYED TO PRODUCTION.
Poornachand200 commented 3 months ago

@peter-evans Hope the explanation in the above comment helps.

Poornachand200 commented 2 months ago

@peter-evans Can you please assist with the above response? It will be of great help. The development activity can resume only if this is rectified.

Poornachand200 commented 2 months ago

@peter-evans Looking for a response from you as we are highly depend on this to push our code to production. If my above explanation is not clear, I can set up a session with you. Please let me know what works.

Poornachand200 commented 2 months ago

@peter-evans Kindly update on this.

Poornachand200 commented 2 months ago

@peter-evans Please update on this. We are blocked on this.

peter-evans commented 2 months ago

@Poornachand200 It looks like the latest changes you made to the workflow are following the example here, so that part looks fine.

The problem seems to be that you want to ignore parts of the diff for some paths. For that you should use the add-paths input, but you will need to change the value of the input based on the value of inputs.product.

The other alternative is to create your own commits, and then discard any changes that you don't want.

I'm very busy at the moment and that's about all I have time for to help you with this.

I'll close this now because this isn't an issue with the action itself, it's just general support for using the action. I try to help with these type of requests, but I don't have a lot of time to provide support in my spare time.