From 53b6f9e72f15742fdcf7f68d5abfdb49bcb236e1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:44:30 +0900 Subject: [PATCH] feat/fixAutoPR (#47) * fix: Auto PR behavior * fix: 'main' as a base for chenge detections * feat: Create PR only if there've been PR for its' branch yet * fix: Modify condition --------- Co-authored-by: atsuyaw <68371029+atsuyaw@users.noreply.github.com> --- .github/workflows/release.yml | 52 +++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 44c8b56e..77bb2c18 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,9 @@ name: Release "on": - create: - pull_request: - types: [opened, synchronize] + push: + branchs-ignore: + - main workflow_dispatch: concurrency: @@ -11,27 +11,47 @@ concurrency: cancel-in-progress: true jobs: - openPR: + get-changes: runs-on: ubuntu-22.04 - permissions: - pull-requests: write + outputs: + updCont: ${{ steps.updCont.outputs.any_changed }} + dev: ${{ steps.dev.outputs.any_changed }} + existPR: ${{ steps.existPR.outputs.cnt }} steps: - uses: actions/checkout@v4 - - uses: tj-actions/changed-files@v45 + - name: Check updCont + uses: tj-actions/changed-files@v45 id: updCont with: + base_sha: 'main' files: | content/** data/** - - uses: tj-actions/changed-files@v45 - id: updSrc + - name: Check dev + uses: tj-actions/changed-files@v45 + id: dev with: + base_sha: 'main' files: | - * !content/** !data/** + - name: Check exist PR + id: existPR + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "cnt=$(gh pr list -B main -H ${{ github.ref_name }} | wc -l)" \ + >> $GITHUB_OUTPUT + createPR: + runs-on: ubuntu-22.04 + needs: + - get-changes + permissions: + pull-requests: write + steps: + - uses: actions/checkout@v4 - name: Create PR - if: ${{ github.event_name }} != create + if: needs.get-changes.outputs.existPR == 0 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -42,14 +62,16 @@ jobs: --body "" \ --draft - name: Mark as post - if: steps.updCont.outputs.any_changed == true + if: needs.get-changes.outputs.updCont == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh pr edit "${{ github.ref_name }}" --add-label "create post" + gh pr edit "${{ github.ref_name }}" \ + --add-label "documentation" - name: Mark as dev - if: steps.updSrc.outputs.any_changed == true + if: needs.get-changes.outputs.dev == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh pr edit "${{ github.ref_name }}" --add-label "development" + gh pr edit "${{ github.ref_name }}" \ + --add-label "enhancement"