Skip to content

Commit ce1698f

Browse files
committed
feat: added github workflow action file for leetcode Directory.md file
1 parent c4e557f commit ce1698f

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# The objective of this GitHub Action is to update the leetcode DIRECTORY.md file (if needed)
2+
# when doing a git push
3+
name: leetcode_directory_writer
4+
on:
5+
push:
6+
paths:
7+
- 'leetcode/src/**.cpp'
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
- uses: actions/setup-python@v4
16+
with:
17+
python-version: 3.x
18+
- name: Add python dependencies
19+
run: |
20+
pip install requests
21+
- name: Write LeetCode DIRECTORY.md
22+
run: |
23+
python3 scripts/leetcode_directory_md.py 2>&1 | tee leetcode/DIRECTORY.md
24+
git pull || true
25+
- name: Commit and push changes
26+
uses: stefanzweifel/git-auto-commit-action@v4
27+
id: commit-push
28+
with:
29+
commit_message: 'docs: updating `leetcode/DIRECTORY.md`'
30+
branch: 'leetcode-directory-${{ github.sha }}'
31+
create_branch: true
32+
- name: Creating and merging the PR
33+
shell: bash
34+
if: steps.commit-push.outputs.changes_detected == 'true'
35+
run: |
36+
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).'
37+
gh pr merge --admin --merge --subject 'docs: updating `leetcode/DIRECTORY.md' --delete-branch
38+
env:
39+
GH_TOKEN: ${{ github.token }}

leetcode/DIRECTORY.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)