joshcai / leetcode-sync

GitHub Action for syncing LeetCode submissions to GitHub
303 stars 61 forks source link

Add verbose and commit-header functionality #46

Closed ravibrock closed 1 year ago

ravibrock commented 1 year ago

Verbose

Added an option to display additional information about submissions in commit logs and folder names.

Commit header

The prefix for automated commits is now changeable. I made some other changes to commit formatting that serve to reduce redundancy and provide more novel information about each commit while still keeping the automated messages reasonably concise.

Folders

I also made it optional to always put problems into their own repo (so that each submission folder can be in the repo's base directory if desired, while still potentially segregating submissions into per-user repos for collaboration).

Miscellaneous

There are also some small tweaks like adding newlines at the end of submission files - recommended for git, but not added automatically by Leetcode. Some diffs are also caused by my Vim config stripping spaces from the end of lines or adding newlines at the bottoms of code files.

Other

The README yaml example might need updating with a new tag if this is merged. Not sure but didn't want to add a new release/tag myself.

Images:

The screenshot below was generated by this yaml (linked to my fork for testing):

name: Sync Leetcode

on:
  workflow_dispatch:
  schedule:
    - cron: "0 0 * * *"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Sync
        uses: ravibrock/leetcode-sync@v1.6
        with:
          github-token: ${{ github.token }}
          leetcode-csrf-token: ${{ secrets.CSRFTOKEN }}
          leetcode-session: ${{ secrets.LEETCODE_SESSION }}
          verbose: true
          commit-header: '[LC Sync]'

Screenshot 2023-08-10 at 18 07 31

And the last screenshot by this one:

name: Sync Leetcode

on:
  workflow_dispatch:
  schedule:
    - cron: "0 0 * * *"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Sync
        uses: ravibrock/leetcode-sync@v1.6
        with:
          github-token: ${{ github.token }}
          leetcode-csrf-token: ${{ secrets.CSRFTOKEN }}
          leetcode-session: ${{ secrets.LEETCODE_SESSION }}
          destination-folder: 'problems'
          verbose: false
          commit-header: '[LC Sync]'

Screenshot 2023-08-10 at 18 43 35

ravibrock commented 1 year ago

Should be done now, thank you!

joshcai commented 1 year ago

Thank you!