Skip to content

Chore: [ELI-811] - Added workflow for nbs preprod data #275

Chore: [ELI-811] - Added workflow for nbs preprod data

Chore: [ELI-811] - Added workflow for nbs preprod data #275

Workflow file for this run

name: PR Link ticket
on:
pull_request:
types: [ opened ]
jobs:
link-ticket:
runs-on: ubuntu-22.04
env:
REF: ${{ github.event.pull_request.head.ref }}
permissions:
id-token: write
pull-requests: write
issues: write
steps:
- name: Check ticket name conforms to requirements
run: echo "$REF" | grep -i -E -q "(eli-[0-9]+)|(dependabot\/)"
continue-on-error: true
- name: Grab ticket name
if: contains(github.event.pull_request.head.ref, 'eli-')
continue-on-error: true
run: |
# Match ticket name patterns
REGEX='(eli-[0-9]+)'
# Remove whitespace and newlines from the regex
REGEX=$(echo "$REGEX" | tr -d '[:space:]')
# Extract the ticket name and convert to uppercase
TICKET_NAME=$(echo "$REF" | grep -i -E -o "$REGEX" | tr '[:lower:]' '[:upper:]')
# Set the environment variable
echo "TICKET_NAME=$TICKET_NAME" >> "$GITHUB_ENV"
- name: Comment on PR with link to JIRA ticket
if: contains(github.event.pull_request.head.ref, 'eli-')
continue-on-error: true
uses: actions/github-script@v9
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `This branch is work on a ticket in an NHS England JIRA Project. Here is a handy link to the ticket:
[${{ env.TICKET_NAME }}](https://nhsd-jira.digital.nhs.uk/browse/${{ env.TICKET_NAME }})`
})