Skip to content

feat(j-s): Enable sort by state in tables #14654

feat(j-s): Enable sort by state in tables

feat(j-s): Enable sort by state in tables #14654

name: PR close
on:
pull_request:
types:
- closed
defaults:
run:
shell: bash
jobs:
check-unicorn:
name: Is this a unicorn PR
if: github.event.pull_request.merged == true
runs-on: arc-runners
timeout-minutes: 10
outputs:
IS_UNICORN: ${{ steps.unicorn_affected.outputs.IS_UNICORN }}
LATEST_RELEASE: ${{ steps.get_latest_release.outputs.LATEST_RELEASE }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- name: Setup yarn
run: corepack enable
- name: Get cache
id: get-cache
uses: ./.github/actions/get-cache
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
enable-cache: 'node_modules'
- name: Derive appropriate SHAs
uses: nrwl/nx-set-shas@v4
- run: |
echo "BASE: ${{ env.NX_BASE }}"
echo "HEAD: ${{ env.NX_HEAD }}"
- name: Check unicorn affected
id: unicorn_affected
run: |
echo "Comparing nx affected for ${{ env.NX_HEAD }} using ${{ env.NX_BASE }} as base branch"
echo IS_UNICORN=$(node scripts/ci/unicorn-utils.mjs "{\"head\": \"${{ env.NX_HEAD }}\", \"base\": \"${{ env.NX_BASE }}\" }") >> "$GITHUB_OUTPUT"
- name: Results
run: |
echo "Unicorn = ${{ steps.unicorn_affected.outputs.IS_UNICORN }}"
- name: Find Latest Release Branch
if: ${{ steps.unicorn_affected.outputs.IS_UNICORN == 'true' }}
id: get_latest_release
run: |
LATEST_RELEASE="$(node scripts/ci/get-last-release.mjs $(git branch -r))"
echo LATEST_RELEASE=$LATEST_RELEASE >> "$GITHUB_OUTPUT"
- run: "echo 'latest release: ${{ steps.get_latest_release.outputs.LATEST_RELEASE }}'"
- name: Create a PR
if: ${{ steps.unicorn_affected.outputs.IS_UNICORN == 'true' }}
id: create_pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BRANCH: ${{ github.head_ref}}/cherry-pick
TARGET_BRANCH: release/${{ steps.get_latest_release.outputs.LATEST_RELEASE }}
run: |
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }} (automated)"
echo ${{ github.event.pull_request.merge_commit_sha }}
echo ${{ github.head_ref}}
git checkout $TARGET_BRANCH
git checkout -b $PR_BRANCH
git cherry-pick -x ${{ github.event.pull_request.merge_commit_sha }}
git commit --allow-empty -am "Automated cherry-pick of ${{ github.event.pull_request.merge_commit_sha }}"
git push --set-upstream origin $PR_BRANCH
echo "new branch created"
PR=$(gh pr create -B $TARGET_BRANCH -H $PR_BRANCH --title "Automated cherry-pick of ${{ github.event.pull_request.merge_commit_sha }}" --body "Automated cherry-pick of ${{ github.event.pull_request.merge_commit_sha }}")
echo "$PR created"
echo PR=$PR >> "$GITHUB_OUTPUT"
- name: Send slack message
if: ${{ steps.unicorn_affected.outputs.IS_UNICORN == 'true' }}
uses: slackapi/[email protected]
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
text: "A new PR has been created: ${{ steps.create_pr.outputs.PR }}"
cleanup:
name: Clean up feature deployment
runs-on: arc-runners
steps:
- name: Get git branch
run: |
set -euo pipefail
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF/refs\/heads\//}}"
echo "GIT_BRANCH=$GIT_BRANCH" >> "$GITHUB_ENV"
- name: Generate deployment branch name
id: git-branch-deploy
run: |
set -euo pipefail
GIT_BRANCH_DEPLOY="$GIT_BRANCH"
if [[ ! ("$GIT_BRANCH_DEPLOY" =~ "feature/") ]]; then
# If event is pull request but branch is not prefixed with feature/
GIT_BRANCH_DEPLOY=feature/$GIT_BRANCH_DEPLOY
fi
# Avoid too long resource names
GIT_BRANCH_DEPLOY="${GIT_BRANCH_DEPLOY:0:50}"
echo "GIT_BRANCH_DEPLOY=$GIT_BRANCH_DEPLOY" >> "$GITHUB_ENV"
- name: Clean up feature
env:
SPINNAKER_WEBHOOK_TOKEN: ${{ secrets.SPINNAKER_WEBHOOK_TOKEN }}
SPINNAKER_URL: https://spinnaker-gate.shared.devland.is
run: |
set -euo pipefail
curl "$SPINNAKER_URL/webhooks/webhook/feature-cleanup" -H "content-type: application/json" --data-binary @- <<BODY
{
"token": "$SPINNAKER_WEBHOOK_TOKEN",
"parameters": {
"feature_name": "$(echo "$GIT_BRANCH_DEPLOY" | cut -d"/" -f2- | tr -cd '[:alnum:]-' | tr '[:upper:]' '[:lower:]' | cut -c1-50)"
}
}
BODY