Skip to content

Commit

Permalink
feat/fixAutoPR (#47)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
github-actions[bot] and atsuyaw authored Oct 23, 2024
1 parent 955ad54 commit 53b6f9e
Showing 1 changed file with 37 additions and 15 deletions.
52 changes: 37 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,57 @@
name: Release

"on":
create:
pull_request:
types: [opened, synchronize]
push:
branchs-ignore:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
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: |
Expand All @@ -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"

0 comments on commit 53b6f9e

Please sign in to comment.