8000 Create PR rather than direct commit (directory workflow) (#24) · TheAlgorithms/scripts@124f337 · GitHub
[go: up one dir, main page]

Skip to content

Commit 124f337

Browse files
Create PR rather than direct commit (directory workflow) (#24)
* Create PR rather than direct commit (directory workflow) * chore: apply suggestions from code review Co-authored-by: Taj <tjgurwara99@users.noreply.github.com> --------- Co-authored-by: Taj <tjgurwara99@users.noreply.github.com>
1 parent d10fd51 commit 124f337

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

directory_md/action.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,27 @@ runs:
2626
- name: Set up Python
2727
uses: actions/setup-python@v4
2828
with:
29-
python-version: '3.10' # or whatever version you support
29+
python-version: '3.x'
3030
- name: Setup Git configurations
3131
shell: bash
3232
run: |
3333
git config --global user.name github-actions[bot]
3434
git config --global user.email 'github-actions@users.noreply.github.com'
35-
- name: Running the formatter
35+
- name: Running the directory builder
3636
shell: bash
3737
run: |
3838
python build_directory_md.py ${{ inputs.language }} ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignored-directories }} ${{ inputs.ignore-folders-children }} > DIRECTORY.md
3939
- name: Committing changes
4040
shell: bash
4141
run: |
42-
git commit -m "chore: update `DIRECTORY.md`" DIRECTORY.md || true
43-
git push origin HEAD:$GITHUB_REF || true
42+
git branch directory-update
43+
git checkout directory-update
44+
45+
git commit -m "docs: update `DIRECTORY.md`" DIRECTORY.md || true
46+
git push origin directory-update:directory-update --force
47+
- name: Creating a pull request
48+
shell: bash
49+
run: |
50+
if [[ `git status --porcelain` ]]; then
51+
gh pr create --base ${GITHUB_REF##*/} --head directory-update --title 'docs: updating `DIRECTORY.md`' --body 'Updated the `DIRECTORY.md` file (see the diff. for changes).' || true
52+
# `true` is needed in case the PR has been already created to prevent the CI to fail. The changes will already be pushed to the current PR's branch.

0 commit comments

Comments
 (0)
0