From 80bc4c3060ffbcf1cd707010736e00c80f54e97e Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Tue, 3 Oct 2023 14:02:58 +0530 Subject: [PATCH 1/2] dev: update sync workflow to run only when the source repo is configured --- .github/workflows/create-sync-pr.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/create-sync-pr.yml b/.github/workflows/create-sync-pr.yml index 9959962635b..32fd8ae9943 100644 --- a/.github/workflows/create-sync-pr.yml +++ b/.github/workflows/create-sync-pr.yml @@ -14,17 +14,27 @@ jobs: pull-requests: write contents: read steps: + - name: Check SOURCE_REPO + id: check_repo + env: + SOURCE_REPO: ${{ secrets.SOURCE_REPO }} + run: | + echo "::set-output name=is_correct_repo::$(if [[ "$SOURCE_REPO" == "makeplane/plane" ]]; then echo 'true'; else echo 'false'; fi)" + - name: Checkout Code + if: steps.check_repo.outputs.is_correct_repo == 'true' uses: actions/checkout@v2 with: persist-credentials: false fetch-depth: 0 - name: Set up Branch Name + if: steps.check_repo.outputs.is_correct_repo == 'true' run: | echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV - name: Setup GH CLI + if: steps.check_repo.outputs.is_correct_repo == 'true' 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 @@ -34,6 +44,7 @@ jobs: sudo apt install gh -y - name: Create Pull Request + if: steps.check_repo.outputs.is_correct_repo == 'true' env: GH_TOKEN: ${{ secrets.TOKEN }} run: | From f571fa306a1f279cd2285051507a7996b51ce8c0 Mon Sep 17 00:00:00 2001 From: sriramveeraghanta Date: Tue, 3 Oct 2023 15:34:40 +0530 Subject: [PATCH 2/2] fix: naming convention changes --- ...equest.yml => build-test-pull-request.yml} | 0 .github/workflows/create-sync-pr.yml | 47 +++++++++---------- ...er_Images.yml => update-docker-images.yml} | 0 3 files changed, 23 insertions(+), 24 deletions(-) rename .github/workflows/{Build_Test_Pull_Request.yml => build-test-pull-request.yml} (100%) rename .github/workflows/{Update_Docker_Images.yml => update-docker-images.yml} (100%) diff --git a/.github/workflows/Build_Test_Pull_Request.yml b/.github/workflows/build-test-pull-request.yml similarity index 100% rename from .github/workflows/Build_Test_Pull_Request.yml rename to .github/workflows/build-test-pull-request.yml diff --git a/.github/workflows/create-sync-pr.yml b/.github/workflows/create-sync-pr.yml index 32fd8ae9943..6ca84019700 100644 --- a/.github/workflows/create-sync-pr.yml +++ b/.github/workflows/create-sync-pr.yml @@ -11,13 +11,13 @@ jobs: if: github.event.pull_request.merged == true runs-on: ubuntu-latest permissions: - pull-requests: write - contents: read + pull-requests: write + contents: read steps: - name: Check SOURCE_REPO id: check_repo env: - SOURCE_REPO: ${{ secrets.SOURCE_REPO }} + 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)" @@ -27,12 +27,12 @@ jobs: with: persist-credentials: false fetch-depth: 0 - + - name: Set up Branch Name if: steps.check_repo.outputs.is_correct_repo == 'true' run: | - echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV - + echo "SOURCE_BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV + - name: Setup GH CLI if: steps.check_repo.outputs.is_correct_repo == 'true' run: | @@ -46,23 +46,22 @@ jobs: - name: Create Pull Request if: steps.check_repo.outputs.is_correct_repo == 'true' env: - GH_TOKEN: ${{ secrets.TOKEN }} + GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: | - TARGET_REPO="makeplane/${{ secrets.REPO_NAME }}" - TARGET_BRANCH="${{ secrets.REPO_TARGET_BRANCH }}" - SOURCE_BRANCH="${{ env.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 + 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 }}" - 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 - + gh pr create \ + --base $TARGET_BRANCH \ + --head $SOURCE_BRANCH \ + --title "$PR_TITLE" \ + --body "$PR_BODY" \ + --repo $TARGET_REPO diff --git a/.github/workflows/Update_Docker_Images.yml b/.github/workflows/update-docker-images.yml similarity index 100% rename from .github/workflows/Update_Docker_Images.yml rename to .github/workflows/update-docker-images.yml