Code Monkey home page Code Monkey logo

Comments (3)

peter-evans avatar peter-evans commented on July 18, 2024

Hi @Poornachand200

The reason this isn't working is not the message you see in the logs about detached HEAD, it's this line here:
Branch 'release/pingfederate-test-to-production' is not ahead of base 'main' and will not be created

Please follow this example:
https://github.com/peter-evans/create-pull-request/blob/main/docs/examples.md#keep-a-branch-up-to-date-with-another

My understanding is that you want to update main from the specified tag. So your solution should look something like this:

jobs:
  productionPromotion:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: main
      - name: Reset main branch to match the specified tag
        run: |
          git fetch origin ${{ inputs.tag }}:${{ inputs.tag }}
          git reset --hard ${{ inputs.tag }}
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v6
        with:
          branch: "release/${{inputs.product}}-test-to-production"

I've never tried to use this method with a tag before, so it will be interesting to hear if it works ok.

from create-pull-request.

Poornachand200 avatar Poornachand200 commented on July 18, 2024

I tried updating the workflow like this. Attached the screen shot of the pull request and the extracted logs.

The below screen shot in create pull request steps shows only file is modified and will be added. But the created PR has the file which is copied in copy step in below. I need to ignore the file in test folder after copy step. The PR shouldn't have the test folder changes.

      - 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

Skärmbild 2024-03-05 132513

logs_21761108848.zip

PR creation

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
      tag:
        description: 'tag 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

      #- uses: actions/checkout@v4
      #  with:
      #    ref: ${{ inputs.tag }}
      #    fetch-depth: 0

      - name: Reset main branch to match the specified tag
        run: |
          git fetch origin ${{ inputs.tag }}:${{ inputs.tag }}
          git reset --hard ${{ inputs.tag }}

      - name: Git status
        run: git status

      - 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: Commit and push files to the tag
      #  run: |
      #    git config --local user.email "github-actions[bot]@users.noreply.github.com"
      #    git config --local user.name "github-actions[bot]"
      #    git add -A
      #    git commit -a -m "Add changes"
      #    git tag -d ${{ inputs.tag }}
      #    git tag ${{ inputs.tag }}
      #    git push origin :${{ inputs.tag }}
      #    git push origin ${{ inputs.tag }}
          

      - 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"
          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.

from create-pull-request.

Poornachand200 avatar Poornachand200 commented on July 18, 2024

add-paths doesn't seem to work as expected. It also add nuuday-ciam/test which doesn't match.


      - 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"
          add-paths: nuuday-ciam/production/
          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.

from create-pull-request.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.