I want to put some check on creation of PR (pull request) in Github where it would check if the PR title contains any jira ticket id (eg. TES-102) and also it should check if TES-102 is an actual ticket in jira. If it fails to do both of the things then github should not allow to create a PR itself.
There is no way I am aware of to enforce this from Jira's side. But that said, it might be possible to enforce some kind of policy from Github's side of things to allow or prevent such pull requests. However these appear to be 3rd party additions, and not out-of-the-box features.
Check out https://github.com/marketplace/actions/enforce-pull-request-title-includes-jira-issue-key as it appears to get at least part of the way towards your request. However this does not verify the validity of existing issues by itself, it only appears to use a regex to match for valid formats in Jira issuekey syntax.
I came across a post that suggests this can be done if using Github Actions. Check out https://fgiuliani.com/posts/github-action-jira/
But that also doesn't appear to check the Jira site for that specific issue existing.
I also came across this thread, https://stackoverflow.com/questions/55054210/any-plugin-for-github-to-enforce-jira-issue-key-in-commits which would seem to indicate this could be possible in Github Enterprise edition (not Github.com) through the use of pre-receive hooks.
Sorry this does not exactly answer your specific ask here, but I have not yet found an exact way to enforce this.
Hello Community! Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events