chore: improve the LeetCode directory writer (#1276)

* chore: free-dependency LeetCode directory writer

* updating DIRECTORY.md

---------

Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
This commit is contained in:
David Leal 2023-06-13 10:13:34 -06:00 committed by GitHub
parent b1a8da69a8
commit 2e8374e5c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View File

@ -7,6 +7,7 @@ on:
- "leetcode/src/**.c" - "leetcode/src/**.c"
jobs: jobs:
build: build:
if: github.repository == 'TheAlgorithms/C' # We only need this to run in our repository.
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -21,17 +22,21 @@ jobs:
- name: Write LeetCode DIRECTORY.md - name: Write LeetCode DIRECTORY.md
run: | run: |
python3 scripts/leetcode_directory_md.py 2>&1 | tee leetcode/DIRECTORY.md python3 scripts/leetcode_directory_md.py 2>&1 | tee leetcode/DIRECTORY.md
- name: Commit and push changes - name: Setup Git configurations
uses: stefanzweifel/git-auto-commit-action@v4
id: commit-push
with:
commit_message: "docs: updating `leetcode/DIRECTORY.md`"
branch: "leetcode-directory-${{ github.sha }}"
create_branch: true
- name: Creating and merging the PR
shell: bash shell: bash
if: steps.commit-push.outputs.changes_detected == 'true'
run: | run: |
git config --global user.name github-actions[bot]
git config --global user.email 'github-actions@users.noreply.github.com'
- name: Committing changes
shell: bash
run: |
git checkout -b leetcode-directory-${{ github.sha }}
git commit -m "docs: updating `leetcode/DIRECTORY.md`
git push origin leetcode-directory-${{ github.sha }}:leetcode-directory-${{ github.sha }}
- name: Creating the pull request
shell: bash
run: |
if [[ `git status --porcelain` ]]; then
gh pr create --base ${GITHUB_REF##*/} --head leetcode-directory-${{ github.sha }} --title 'docs: updating `leetcode/DIRECTORY.md`' --body 'Updated LeetCode directory (see the diff. for changes).' gh pr create --base ${GITHUB_REF##*/} --head leetcode-directory-${{ github.sha }} --title 'docs: updating `leetcode/DIRECTORY.md`' --body 'Updated LeetCode directory (see the diff. for changes).'
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}

View File

@ -107,6 +107,7 @@
* [Queue](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/queue/queue.c) * [Queue](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/queue/queue.c)
* [Stack](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/stack.c) * [Stack](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/stack.c)
* Stack * Stack
* [Dynamic Stack](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/stack/dynamic_stack.c)
* [Main](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/stack/main.c) * [Main](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/stack/main.c)
* [Parenthesis](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/stack/parenthesis.c) * [Parenthesis](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/stack/parenthesis.c)
* [Stack](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/stack/stack.c) * [Stack](https://github.com/TheAlgorithms/C/blob/HEAD/data_structures/stack/stack.c)