klip-sdk
Version:
JavaScript SDK to interact with klip App2App requests
80 lines (77 loc) • 2.61 kB
YAML
name: Create Pull Request
author: Bolt lee
description: 'Pull Request'
outputs:
tag:
description: 'tag by developer'
value: ${{ steps.vars.outputs.tag }}
rctag:
description: 'rctag by developer'
value: ${{ steps.vars.outputs.rctag }}
inputs:
release:
description: target branch
default: ''
required: true
base:
description: target branch
default: master
required: false
pat:
description: target branch
default: ''
required: true
runs:
using: "composite"
steps:
- name: Set output
id: vars
shell: bash
run: |
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: gh auth login
shell: bash
run: |
echo ${{ env.PAT }} | gh auth login --with-token
env:
PAT: ${{ inputs.pat }}
- name: Check if branch exists already
id: val
shell: bash
run: |
echo "check=$( echo "true" )" >> $GITHUB_OUTPUT
TAG=$(echo "${{ steps.vars.outputs.tag }}" | sed 's/\s//g')
echo ${TAG}
echo ${TAG%-*}
VERSION=$(gh pr list -s open -H release/${TAG%-*} --json headRefName | jq '.[] | .headRefName')
echo $VERSION
if [[ $VERSION == *"release/${TAG%-*}"* ]]; then
echo "release/${TAG%-*} PR already exist"
echo "check=$( echo "false" )" >> $GITHUB_OUTPUT
echo "release/${TAG%-*} branch commit update"
git checkout -b release/${TAG%-*}
git push -f origin release/${TAG%-*}
fi
- name: Create release/tag branch
if: ${{ steps.val.outputs.check == 'true' }}
id: tagging
shell: bash
run: |
echo "PR not exist."
TAG=$(echo "${{ steps.vars.outputs.tag }}" | sed 's/\s//g' | sed -E 's|(\-.*)||')
echo "Create ${TAG} "
echo "Create ${{ steps.vars.outputs.tag }} "
echo "Create to release branch: release/${TAG}"
echo "echo ${{ github.ref_name }}"
git checkout -b release/$TAG
git remote -v
git push origin release/$TAG
echo "TAG=$TAG" >> $GITHUB_OUTPUT
- name: create pull request (master)
if: ${{ steps.val.outputs.check == 'true' }}
shell: bash
run: |
gh pr create --base ${{ inputs.base }} --title "[Master] release/${{ steps.tagging.outputs.TAG }}_QA-Sign-off" --head release/${{ steps.tagging.outputs.TAG }} \
--body "This PR is automatically created by CI to release a new official version of ${{github.repository }}.\nWhen new version will be released."
env:
GITHUB_TOKEN: ${{ inputs.pat }}