From fbc619cade5f8b7e395780ec5e28cac9601c666a Mon Sep 17 00:00:00 2001 From: David Leal Date: Wed, 8 Mar 2023 02:41:38 +0000 Subject: [PATCH 1/2] Create a pull request instead of committing directly --- directory_md/action.yml | 23 +++++++++++++++-------- formatter/action.yml | 25 +++++++++++++++---------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/directory_md/action.yml b/directory_md/action.yml index 6f7edc3..a8415d3 100644 --- a/directory_md/action.yml +++ b/directory_md/action.yml @@ -27,17 +27,24 @@ runs: uses: actions/setup-python@v4 with: python-version: '3.10' # or whatever version you support - - name: Setup Git configurations - shell: bash - run: | - git config --global user.name github-actions[bot] - git config --global user.email 'github-actions@users.noreply.github.com' - name: Running the formatter shell: bash run: | python build_directory_md.py ${{ inputs.language }} ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignored-directories }} ${{ inputs.ignore-folders-children }} > DIRECTORY.md - - name: Committing changes + + git pull || true + - name: Committing and pushing changes + uses: stefanzweifel/git-auto-commit-action@v4 + id: commit-push + with: + commit_message: "docs: updating `DIRECTORY.md`" + branch: "directory-${{ github.sha }}" + create_branch: true + - name: Creating and merging the PR shell: bash + if: steps.commit-push.outputs.changes_detected == 'true' run: | - git commit -m "chore: update `DIRECTORY.md`" DIRECTORY.md || true - git push origin HEAD:$GITHUB_REF || true + gh pr create --base ${GITHUB_REF##*/} --head directory-${{ github.sha }} --title 'docs: updating `DIRECTORY.md`' --body '`DIRECTORY.md` has been updated (see the diff. for changes).' + gh pr merge --admin --merge --subject 'docs: updating `DIRECTORY.md`' --delete-branch + env: + GH_TOKEN: ${{ github.token }} diff --git a/formatter/action.yml b/formatter/action.yml index cc232b2..6925e64 100644 --- a/formatter/action.yml +++ b/formatter/action.yml @@ -17,19 +17,24 @@ runs: steps: - run: echo "${{ github.action_path }}" >> $GITHUB_PATH shell: bash - - name: Setup Git configurations - shell: bash - run: | - git config --global user.name github-actions[bot] - git config --global user.email 'github-actions@users.noreply.github.com' - name: Running the formatter shell: bash run: | filename_formatter.sh ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignore-files }} - - name: Committing changes + + git pull || true + - name: Committing and pushing changes + uses: stefanzweifel/git-auto-commit-action@v4 + id: commit-push + with: + commit_message: "chore: formatting filenames" + branch: "formatting_files-${{ github.sha }}" + create_branch: true + - name: Creating and merging the PR shell: bash + if: steps.commit-push.outputs.changes_detected == 'true' run: | - git add ${{ inputs.working-directory }} || true - git commit -m "chore: formatting filenames" || true - - git push origin HEAD:$GITHUB_REF || true + gh pr create --base ${GITHUB_REF##*/} --head formatting_files-${{ github.sha }} --title 'chore: formatting filenames' --body 'Formatted filenames (see the diff. for changes).' + gh pr merge --admin --merge --subject 'chore: formatting filenames' --delete-branch + env: + GH_TOKEN: ${{ github.token }} From a51e8eb52b97c622467ec6831abd67c90a8b0302 Mon Sep 17 00:00:00 2001 From: David Leal Date: Thu, 23 Mar 2023 20:36:22 -0600 Subject: [PATCH 2/2] chore: apply suggestions from code review Co-authored-by: Christian Clauss --- directory_md/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/directory_md/action.yml b/directory_md/action.yml index a8415d3..8321888 100644 --- a/directory_md/action.yml +++ b/directory_md/action.yml @@ -26,7 +26,7 @@ runs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.10' # or whatever version you support + python-version: '3.x' # or whatever version you support - name: Running the formatter shell: bash run: |