forked from NHERI-SimCenter/pelicun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14a0345
commit f2ed56d
Showing
2 changed files
with
25 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,29 @@ | ||
name: Code Formatting and Linting | ||
|
||
name: Push commit | ||
on: | ||
push: | ||
pull_request: | ||
|
||
permissions: | ||
contents: write | ||
jobs: | ||
format_and_lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install Black and Flake8 | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install black flake8 | ||
- name: Run Black | ||
run: black -S . | ||
|
||
- name: Check for changes | ||
id: git_status | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
git add . | ||
if git diff-index --quiet HEAD --; then | ||
echo "No changes to commit" > /tmp/git_status_output | ||
else | ||
git commit -m "Format code with Black" | ||
echo "Changes committed" > /tmp/git_status_output | ||
fi | ||
continue-on-error: true | ||
|
||
- name: Read git status output | ||
id: read_git_status | ||
run: cat /tmp/git_status_output | ||
|
||
- name: Push changes | ||
if: steps.read_git_status.outputs.result != 'No changes to commit' | ||
uses: ad-m/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
- name: Install Black and Flake8 | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install black flake8 | ||
- name: Run Black | ||
run: black -S . | ||
- name: Commit changes | ||
run: | | ||
git config --global user.name 'GitHubBot' | ||
git config --global user.email '[email protected]' | ||
git add -u | ||
git commit -am "Format code with black" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters