Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,27 @@ Select all that apply:
- - [ ] Runs workspace upgrades
- - [ ] Has breaking changes
<end></end>
### Jira/Ticket
<end></end>

### Summary
<end></end>
> [!CAUTION]
> The above section is required and must not be manipulated other than checking the check boxes and filling out the summary/ticket information. There is a Github Action that will fail if the pull request template does not conform to this standard. If the ticket information or summary is not filled in it will try to get it from the branch name.

------
------

**Reason for Change**:
<!-- What does this PR improve or fix? -->

**Issue Fixed**:
<!-- If this PR fixes Jira issue REL-1234, add "Fixes REL-1234" to the next line. -->

**Requirements**:
<!-- Put an "X" character inside the brackets of each completed task. Some may be optional depending on the PR. -->

- [ ] follows [commit message convention](https://einstein.kcura.com/pages/viewpage.action?spaceKey=DTT&title=How+to+work+with+git+and+pull+requests)
- [ ] functional tests build pipeline was successful https://trident.kcura.corp/dea/job/Productions/job/Run-Functional-Tests/
- [ ] adds unit tests where appropriate
- [ ] updated changelog
- [ ] add JIRA story for toggle removal (if applicable)

**Notes**:
190 changes: 190 additions & 0 deletions .github/workflows/validate_pr_and_update_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
name: PR Verification and Changelog/Version Update
run-name: ${{ github.actor }} is verifying PR details
on:
pull_request:
types: [opened, synchronize, closed, edited]
jobs:
verify_details:
runs-on: ubuntu-latest
steps:
- name: Get Code
uses: actions/checkout@v4
with:
ref: main
#token: ${{ secrets.SVC_PAT }}

- name: Validate And Process PR Template
id: validate
run: |
changeType="Unknown"
deploymentDetails=""
summary="None"
foundEndTags=0

stop="false"
startTypeCapture="false"
startDeployCapture="false"
startSumCapture="false"
startTaskVerification="false"

branch="${{ github.head_ref || github.ref_name }}"
b="${{ github.event.pull_request.body }}";
mapfile -t StringArray <<< "$b"
for val in "${StringArray[@]}"; do
if [[ "$val" = "<end></end>"* ]]; then
foundEndTags=$((foundEndTags+1))
fi

# echo "Found: $val"
if [[ "$val" = 'Pick **one** of the following:'* ]]; then
startTypeCapture="true"
elif [[ "$val" = "### Deployment Details"* ]]; then
startDeployCapture="true"
elif [[ "$val" = "### Summary"* ]]; then
startSumCapture="true"
elif [[ "$val" = "> [!CAUTION]"* ]]; then
startTaskVerification="true"
fi

# echo "startTypeCapture: $startTypeCapture"
# echo "startDeployCapture: $startDeployCapture"
# echo "startSumCapture: $startSumCapture"
# echo "startTaskVerification: $startTaskVerification"

if [[ "$startTypeCapture" = "true" ]]; then
if [[ "${val,,}" = "- - [x]"* ]]; then
prefix="- - [x] "
changeType="${val:8:100}"
startTypeCapture="found"
fi

if [[ "$val" = "<end></end>"* ]]; then
startTypeCapture="found"
fi
fi

if [[ "$startDeployCapture" = "true" ]]; then
if [[ "${val,,}" = "- - [x]"* ]]; then
prefix="- - [x] "
deploymentDetails="$deploymentDetails(${val:8:100})"
fi

if [[ "$val" = "<end></end>"* ]]; then
startDeployCapture="found"
fi
fi

if [[ "$startSumCapture" = "true" ]]; then
if [[ "$val" = "<end></end>"* ]]; then
startSumCapture="found"
else
summary="$val"
fi
fi

done;

if [[ $foundEndTags -ne 3 ]]; then
echo "PR Template is invalid, expected to find 3 '<end></end>'' tags!!!!"
exit 1
fi
if [[ "$startSumCapture" != "found" ]]; then
echo "PR Template is invalid, expected to find '### Summary' section!!!!"
exit 1
fi
if [[ "$startTypeCapture" != "found" ]]; then
echo "PR Template is invalid, expected to find 'Pick one of the following:' section!!!!"
exit 1
fi
if [[ "$startDeployCapture" != "found" ]]; then
echo "PR Template is invalid, expected to find '### Deployment Details' section!!!!"
exit 1
fi

echo "Found raw change type: $changeType"
echo "Found raw deployment details: $deploymentDetails"
echo "Found raw summary: $summary"

if [[ "$changeType" = "Unknown" ]]; then
echo "No change type!!!!"
exit 1
fi

echo "JIRA_LINK=$ticketLong" >> $GITHUB_OUTPUT

prUrl="https://github.com/relativityone/centralized-review/pull/${{github.event.pull_request.number}}"
changelogLong="[$summary] » [$changeType]"
changelogShort="[$summary]"
if [ "$deploymentDetails" != "" ]; then
changelogLong="$changelogLong - [$deploymentDetails]"
fi
changelogLong="$changelogLong » [PR]($prUrl)"

changelogLong="${changelogLong//[$'\t\r\n']}"
changelogShort="${changelogShort//[$'\t\r\n']}"

echo "Final change log:"
echo $changelogLong

echo "Final change commit message:"
echo $changelogShort

echo "NEW_CHANGELOG_SHORT=$changelogShort" >> $GITHUB_ENV
echo "NEW_CHANGELOG_LONG=$changelogLong" >> $GITHUB_ENV
echo "DEPLOYMENT_DETS=$deploymentDetails" >> $GITHUB_ENV
shell: bash


- name: Update Version
if: github.base_ref == 'main' && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
run: |
version=`cat version.txt`
changeType="${{ env.DEPLOYMENT_DETS }}"
if [[ "$changeType" = *"Has breaking changes"* ]]; then
echo "Major change"
IFS='.' read -r -a array <<< "$version"
major=${array[0]}
major=$((major+1))
version="$major.0.0"
elif [[ "$changeType" = *"Cannot be rolled back"* || "$changeType" = *"Runs workspace upgrades"* ]]; then
echo "Minor change"
IFS='.' read -r -a array <<< "$version"
major=${array[0]}
minor=${array[1]}
minor=$((minor+1))
version="$major.$minor.0"
else
echo "Small change"
IFS='.' read -r -a array <<< "$version"
major=${array[0]}
minor=${array[1]}
patch=${array[2]}
patch=$((patch+1))
version="$major.$minor.$patch"
fi
echo "Updating to $version"
echo "$version" > "version.txt"
echo "NEW_VERSION=$version" >> $GITHUB_ENV
shell: bash

- name: Update Changelog
if: github.base_ref == 'main' && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
run: |
changelog="${{ env.NEW_CHANGELOG_LONG }}"
version="${{ env.NEW_VERSION }}"
versionText="#### $version ($(date -I))"
printf '%s\n%s\n' "" "$(cat CHANGELOG.md)" > CHANGELOG.md
printf '%s\n%s\n' "$changelog" "$(cat CHANGELOG.md)" > CHANGELOG.md
printf '%s\n%s\n\n' "$versionText" "$(cat CHANGELOG.md)" > CHANGELOG.md
shell: bash

- name: Push changelog and version to main
if: github.base_ref == 'main' && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
run: |
version="${{ env.NEW_VERSION }}"
git config user.name 'GitHub Action'
git config user.email 'svc_review-center.github-actions@relativity.com'
git add .
git commit -m "[$version] Update version and change log"
git push origin main
shell: bash
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.9
0.0.10
Loading