diff --git a/.github/workflows/ReviewBot.yml b/.github/workflows/ReviewBot.yml new file mode 100644 index 0000000..4b63530 --- /dev/null +++ b/.github/workflows/ReviewBot.yml @@ -0,0 +1,37 @@ +name: ReviewBot +run-name: ReviewBot is linking stacked child pull-requests +on: + pull_request: + types: + - opened + - reopened + - edited +jobs: + comment: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MAIN_BRANCH_NAME: 'main' + BASE_PR_REF: ${{ github.base_ref }} + MY_PR_ID: ${{ github.event.number }} + MY_PR_URL: 'https://github.com/SteveBurkert/github_reviewee/pull/${{ github.event.number }}' + steps: + - name: Check out repository code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready." + - run: | + for base_pr_id in $(gh pr list --search "head:${{ env.BASE_PR_REF }}" --json number --jq '.[].number'); do + gh pr comment ${{ env.MY_PR_ID }} --body "➡️ This pull request seems to be child of: [$base_pr_id](https://github.com/SteveBurkert/github_reviewee/pull/$base_pr_id)." + if [ ${{ env.MAIN_BRANCH_NAME }} == $( gh pr view $base_pr_id --json baseRefName --jq '.baseRefName') ]; then + gh pr comment ${{ env.MY_PR_ID }} --body "➡️ This seems to be the first child Pull-Request of [the base PR $base_pr_id](https://github.com/SteveBurkert/github_reviewee/pull/$base_pr_id). Merge this PR and continue with the base afterwards." + gh pr comment $base_pr_id --body "➡️ [New child Pull-Request added](${{ env.MY_PR_URL }}). Please merge all children first." + gh pr comment $base_pr_id --body "💡 This seems to be the root pull-request with open children. I will convert this PR to a draft now." + gh pr ready $base_pr_id --undo + else + gh pr comment ${{ env.MY_PR_ID }} --body "➡️ This seems to be a child Pull-Request, but not the first. Please merge [the base PR $base_pr_id](https://github.com/SteveBurkert/github_reviewee/pull/$base_pr_id) before this PR." + gh pr comment $base_pr_id --body "➡️ [New child Pull-Request added](${{ env.MY_PR_URL }})." + fi + done diff --git a/.github/workflows/test_label_workflow.yml b/.github/workflows/test_label_workflow.yml deleted file mode 100644 index 520d580..0000000 --- a/.github/workflows/test_label_workflow.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Label issues -run-name: ${{ github.actor }} is learning GitHub Actions -on: - issues: - types: - - reopened - - opened -jobs: - label_issues: - runs-on: ubuntu-latest - permissions: - issues: write - steps: - - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ["triage"] - }) diff --git a/Another_file b/Another_file new file mode 100644 index 0000000..b0b9fc8 --- /dev/null +++ b/Another_file @@ -0,0 +1 @@ +Another file