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