From 750b1119b4247a1259c7be509a4e9dc323f24fa7 Mon Sep 17 00:00:00 2001 From: wanglusheng Date: Thu, 6 Feb 2025 22:23:00 +0800 Subject: [PATCH 1/4] update actions --- .github/workflows/auto_format_docs.yml | 44 +++++++++++------------- .github/workflows/auto_format_python.yml | 38 ++++++++------------ 2 files changed, 35 insertions(+), 47 deletions(-) diff --git a/.github/workflows/auto_format_docs.yml b/.github/workflows/auto_format_docs.yml index bb98ae7..c1f223d 100644 --- a/.github/workflows/auto_format_docs.yml +++ b/.github/workflows/auto_format_docs.yml @@ -1,4 +1,4 @@ -name: Format Code +name: Auto Format Config files & Docs on: push: @@ -11,34 +11,30 @@ on: jobs: format: runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout code + - if: github.event_name == 'push' + uses: actions/checkout@v2 + - if: github.event_name == 'pull_request' uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 with: - node-version: "16" - - - name: Install Prettier - run: | - npm install --save-dev prettier + ref: ${{ github.head_ref }} - - name: Format YAML and Markdown files - run: | - npx prettier --write "**/*.yml" "**/*.md" - - - name: Check for changes - id: check_changes - run: | - git diff --exit-code || echo "Changes detected" + - name: Run Black + uses: actionsx/prettier@v2 + with: + # prettier CLI arguments. + args: --write "**/*.yml" "**/*.md" - name: Commit changes - if: steps.check_changes.outputs.exit_code != 0 - run: | - git config --local user.name "github-actions" - git config --local user.email "github-actions@github.com" - git add . - git commit -m "Format YAML and Markdown files with Prettier" || echo "No changes to commit" - git push + id: commit_changes + uses: peter-evans/create-pull-request@v7 + with: + commit-message: format & update for python + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> + signoff: false + delete-branch: true diff --git a/.github/workflows/auto_format_python.yml b/.github/workflows/auto_format_python.yml index 2b0079e..6e2ede0 100644 --- a/.github/workflows/auto_format_python.yml +++ b/.github/workflows/auto_format_python.yml @@ -11,35 +11,27 @@ on: jobs: format: runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout code + - if: github.event_name == 'push' + uses: actions/checkout@v2 + - if: github.event_name == 'pull_request' uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 with: - python-version: "3.8" - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install black + ref: ${{ github.head_ref }} - name: Run Black - run: | - black . - - - name: Check for changes - id: check_changes - run: | - git diff --exit-code || echo "Changes detected" + uses: datadog/action-py-black-formatter@v2 - name: Commit changes - if: steps.check_changes.outputs.exit_code != 0 - run: | - git config --local user.name "github-actions" - git config --local user.email "github-actions@github.com" - git add . - git commit -m "Format Python code with Black" || echo "No changes to commit" - git push + id: commit_changes + uses: peter-evans/create-pull-request@v7 + with: + commit-message: format & update for python + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> + signoff: false + delete-branch: true From 4572f24fd3689f597bebfc99899936d3437293d8 Mon Sep 17 00:00:00 2001 From: wanglusheng Date: Thu, 6 Feb 2025 22:30:06 +0800 Subject: [PATCH 2/4] update checkout --- .github/workflows/auto_format_docs.yml | 10 +++++----- .github/workflows/auto_format_python.yml | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/auto_format_docs.yml b/.github/workflows/auto_format_docs.yml index c1f223d..0b66c84 100644 --- a/.github/workflows/auto_format_docs.yml +++ b/.github/workflows/auto_format_docs.yml @@ -16,23 +16,23 @@ jobs: steps: - name: Checkout code - - if: github.event_name == 'push' - uses: actions/checkout@v2 - - if: github.event_name == 'pull_request' - uses: actions/checkout@v2 + - if: github.event_name == 'push' + uses: actions/checkout@v4 + - if: github.event_name == 'pull_request' + uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} - name: Run Black uses: actionsx/prettier@v2 with: - # prettier CLI arguments. args: --write "**/*.yml" "**/*.md" - name: Commit changes id: commit_changes uses: peter-evans/create-pull-request@v7 with: + token: ${{ secrets.GITHUB_TOKEN }} commit-message: format & update for python committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> diff --git a/.github/workflows/auto_format_python.yml b/.github/workflows/auto_format_python.yml index 6e2ede0..30a67a8 100644 --- a/.github/workflows/auto_format_python.yml +++ b/.github/workflows/auto_format_python.yml @@ -16,10 +16,10 @@ jobs: steps: - name: Checkout code - - if: github.event_name == 'push' - uses: actions/checkout@v2 - - if: github.event_name == 'pull_request' - uses: actions/checkout@v2 + - if: github.event_name == 'push' + uses: actions/checkout@v4 + - if: github.event_name == 'pull_request' + uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} @@ -30,6 +30,7 @@ jobs: id: commit_changes uses: peter-evans/create-pull-request@v7 with: + token: ${{ secrets.GITHUB_TOKEN }} commit-message: format & update for python committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> From be9a38d63e3509d89c3dd5ef62c98b320af1a3b0 Mon Sep 17 00:00:00 2001 From: wanglusheng Date: Thu, 6 Feb 2025 22:33:59 +0800 Subject: [PATCH 3/4] update --- .github/workflows/auto_format_docs.yml | 1 + .github/workflows/auto_format_python.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/auto_format_docs.yml b/.github/workflows/auto_format_docs.yml index 0b66c84..03ba6ea 100644 --- a/.github/workflows/auto_format_docs.yml +++ b/.github/workflows/auto_format_docs.yml @@ -16,6 +16,7 @@ jobs: steps: - name: Checkout code + run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) - if: github.event_name == 'push' uses: actions/checkout@v4 - if: github.event_name == 'pull_request' diff --git a/.github/workflows/auto_format_python.yml b/.github/workflows/auto_format_python.yml index 30a67a8..5ee71e1 100644 --- a/.github/workflows/auto_format_python.yml +++ b/.github/workflows/auto_format_python.yml @@ -16,6 +16,7 @@ jobs: steps: - name: Checkout code + run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) - if: github.event_name == 'push' uses: actions/checkout@v4 - if: github.event_name == 'pull_request' From 60848ed2042b31f81a250f91fa96343a41630725 Mon Sep 17 00:00:00 2001 From: wanglusheng Date: Thu, 6 Feb 2025 22:36:59 +0800 Subject: [PATCH 4/4] update --- .github/workflows/auto_format_docs.yml | 6 +++--- .github/workflows/auto_format_python.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/auto_format_docs.yml b/.github/workflows/auto_format_docs.yml index 03ba6ea..5b0cb82 100644 --- a/.github/workflows/auto_format_docs.yml +++ b/.github/workflows/auto_format_docs.yml @@ -16,11 +16,11 @@ jobs: steps: - name: Checkout code - run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + run: echo $(echo $GITHUB_REF | cut -d / -f 3) - if: github.event_name == 'push' - uses: actions/checkout@v4 + uses: actions/checkout@v2 - if: github.event_name == 'pull_request' - uses: actions/checkout@v4 + uses: actions/checkout@v2 with: ref: ${{ github.head_ref }} diff --git a/.github/workflows/auto_format_python.yml b/.github/workflows/auto_format_python.yml index 5ee71e1..9be2fd2 100644 --- a/.github/workflows/auto_format_python.yml +++ b/.github/workflows/auto_format_python.yml @@ -16,11 +16,11 @@ jobs: steps: - name: Checkout code - run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + run: echo $(echo $GITHUB_REF | cut -d / -f 3) - if: github.event_name == 'push' - uses: actions/checkout@v4 + uses: actions/checkout@v2 - if: github.event_name == 'pull_request' - uses: actions/checkout@v4 + uses: actions/checkout@v2 with: ref: ${{ github.head_ref }}