2023-10-02 07:58:43 +00:00
|
|
|
name: Create PR in Plane EE Repository to sync the changes
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types:
|
|
|
|
- closed
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
create_pr:
|
|
|
|
# Only run the job when a PR is merged
|
|
|
|
if: github.event.pull_request.merged == true
|
|
|
|
runs-on: ubuntu-latest
|
2023-10-02 09:10:31 +00:00
|
|
|
permissions:
|
2023-10-03 13:11:26 +00:00
|
|
|
pull-requests: write
|
|
|
|
contents: read
|
2023-10-02 07:58:43 +00:00
|
|
|
steps:
|
2023-10-03 13:11:26 +00:00
|
|
|
- name: Check SOURCE_REPO
|
|
|
|
id: check_repo
|
|
|
|
env:
|
|
|
|
SOURCE_REPO: ${{ secrets.SOURCE_REPO_NAME }}
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=is_correct_repo::$(if [[ "$SOURCE_REPO" == "makeplane/plane" ]]; then echo 'true'; else echo 'false'; fi)"
|
|
|
|
|
2023-10-02 07:58:43 +00:00
|
|
|
- name: Checkout Code
|
2023-10-03 13:11:26 +00:00
|
|
|
if: steps.check_repo.outputs.is_correct_repo == 'true'
|
2023-10-02 07:58:43 +00:00
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
persist-credentials: false
|
|
|
|
fetch-depth: 0
|
2023-10-03 13:11:26 +00:00
|
|
|
|
2023-10-02 07:58:43 +00:00
|
|
|
- name: Set up Branch Name
|
2023-10-03 13:11:26 +00:00
|
|
|
if: steps.check_repo.outputs.is_correct_repo == 'true'
|
2023-10-02 07:58:43 +00:00
|
|
|
run: |
|
2023-10-03 13:11:26 +00:00
|
|
|
echo "SOURCE_BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
|
|
|
|
|
2023-10-02 07:58:43 +00:00
|
|
|
- name: Setup GH CLI
|
2023-10-03 13:11:26 +00:00
|
|
|
if: steps.check_repo.outputs.is_correct_repo == 'true'
|
2023-10-02 07:58:43 +00:00
|
|
|
run: |
|
|
|
|
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
|
|
|
|
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
|
|
|
|
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
|
|
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
|
|
|
sudo apt update
|
|
|
|
sudo apt install gh -y
|
|
|
|
|
|
|
|
- name: Create Pull Request
|
2023-10-03 13:11:26 +00:00
|
|
|
if: steps.check_repo.outputs.is_correct_repo == 'true'
|
2023-10-02 07:58:43 +00:00
|
|
|
env:
|
2023-10-03 13:11:26 +00:00
|
|
|
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
2023-10-02 07:58:43 +00:00
|
|
|
run: |
|
2023-10-03 13:11:26 +00:00
|
|
|
TARGET_REPO="${{ secrets.TARGET_REPO_NAME }}"
|
|
|
|
TARGET_BRANCH="${{ secrets.TARGET_REPO_BRANCH }}"
|
|
|
|
SOURCE_BRANCH="${{ env.SOURCE_BRANCH_NAME }}"
|
|
|
|
|
|
|
|
git checkout $SOURCE_BRANCH
|
|
|
|
git remote add target "https://$GH_TOKEN@github.com/$TARGET_REPO.git"
|
|
|
|
git push target $SOURCE_BRANCH:$SOURCE_BRANCH
|
|
|
|
|
|
|
|
PR_TITLE="${{ github.event.pull_request.title }}"
|
|
|
|
PR_BODY="${{ github.event.pull_request.body }}"
|
|
|
|
|
|
|
|
gh pr create \
|
|
|
|
--base $TARGET_BRANCH \
|
|
|
|
--head $SOURCE_BRANCH \
|
|
|
|
--title "$PR_TITLE" \
|
|
|
|
--body "$PR_BODY" \
|
|
|
|
--repo $TARGET_REPO
|