i am getting some pull requests from other branches to merge it to main branch..but before merging i need to check whether the pull request affecting filepath is already exists or not in main branch..because i don’t want to overwrite the old one…if it exists it should echo this file path already exists with complete filepath of pullrequest(adding pr number along with the complete filepath to the message will be good if possible) and may have many subfolders in all branches, need to check all.
consider for ex:
branch1 has folder1/subfolder1/file1.txt
main branch also have folder1/subfolder1/file1.txt with same names
may be i have changed some data to branch1 text file and created a pull request to merge it..it should not merge(shoud not overwrite).it should say already exists and if we don’t have the same path in main branch with same names, then it should create
`name: Check and Create Folder
on:
workflow_dispatch: # Trigger on push to branches
jobs:
check_and_create:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # Checkout code
- name: Check if folder exists
run: |
if [ ! -d "$folderpath" ]; then
echo "Folder does not exist. Creating."
#mkdir "$folderpath"
else
echo "Folder already exists. Skipping creation."
fi
`
Tried to create one github action to check folder path of current repo..when we give folder path manually in script it is checking folder path…but i’m stuck to fetch the affecting folderpath from pullrequest…because i have lots of PR’s, i can’t check each and everyone..i don’t want to overwrite old one..any help would be appreciated..thanks in advance