Skip to content

Commit

Permalink
update actions
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglusheng committed Feb 6, 2025
1 parent ce0f2e2 commit 750b111
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 47 deletions.
44 changes: 20 additions & 24 deletions .github/workflows/auto_format_docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Format Code
name: Auto Format Config files & Docs

on:
push:
Expand All @@ -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 "[email protected]"
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
38 changes: 15 additions & 23 deletions .github/workflows/auto_format_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
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

0 comments on commit 750b111

Please sign in to comment.