Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update actions #26

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 21 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,31 @@ on:
jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout code
run: echo $(echo $GITHUB_REF | cut -d / -f 3)
- 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:
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:
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>
signoff: false
delete-branch: true
40 changes: 17 additions & 23 deletions .github/workflows/auto_format_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,29 @@ on:
jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout code
run: echo $(echo $GITHUB_REF | cut -d / -f 3)
- 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:
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>
signoff: false
delete-branch: true
Loading