Open Poornachand200 opened 4 months ago
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.
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
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.
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.
Subject of the issue:
I am trying to create a pull request from checking out to a tag. I have supplied input base as main. Nevertheless I am facing the error fatal: ref HEAD is not a symbolic ref.
Goal:
I have the required the changes in the tag. peter-evans/create-pull-request@v6 has to create a pull request for the new changes in the existing tag to main branch from the branch "release/${{inputs.product}}-test-to-production" to be created. How to achieve this?
Steps to reproduce
Log