Add format files github action #3
Workflow file for this run
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
name: "format" | ||
on: | ||
pull_request: | ||
branches: [ master ] | ||
types: [opened,closed,synchronize] | ||
env: | ||
python-version: "3.9" | ||
jobs: | ||
cla-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{python-version}} | ||
Check failure on line 17 in .github/workflows/format.yml GitHub Actions / formatInvalid workflow file
|
||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{python-version}} | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install autopep8 | ||
- name: Grant permissions | ||
run: | | ||
chmod u+x "${GITHUB_WORKSPACE}/.github/scripts/format-cpp" | ||
chmod u+x "${GITHUB_WORKSPACE}/.github/scripts/format-py" | ||
- name: Format Codebase | ||
run: | | ||
cd ${GITHUB_WORKSPACE} | ||
"${GITHUB_WORKSPACE}/.github/scripts/format-cpp ${GITHUB_WORKSPACE}" | ||
"${GITHUB_WORKSPACE}/.github/scripts/format-py ${GITHUB_WORKSPACE}" | ||
- name: Commit | ||
run: | | ||
cd ${GITHUB_WORKSPACE} | ||
HAS_CHANGES=$(git diff --cached --name-only) | ||
if [ ${#HAS_CHANGES} -gt 0 ]; then | ||
git commit -m '[Automated Commit] Format Codebase' | ||
git push origin ${{ github.head_ref || github.ref_name }} | ||
fi | ||