ci: Updated workflow to use PAT secret and autocommit actiong (#424) #117
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: ci-normalize-code | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
normalize-code: | |
if: "!startsWith(github.event.head_commit.message, 'bump:')" | |
name: "Normalize code with internal standards" | |
permissions: write-all | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ['3.10'] | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PAT }} | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Run image | |
uses: abatilo/[email protected] | |
with: | |
poetry-version: 1.4.0 | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v4 | |
id: cache | |
with: | |
path: ~/.virtualenvs | |
key: venv-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
venv-${{ matrix.os }}-${{ matrix.python-version }}- | |
- name: Set Poetry config | |
run: | | |
poetry config virtualenvs.in-project false | |
poetry config virtualenvs.path ~/.virtualenvs | |
- name: Install Dependencies | |
run: poetry install --only dev | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Autoformat code if the check fails | |
run: | | |
poetry run isort . | |
poetry run black . | |
- name: Push changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "chore: autoformat isort & black" | |
push_options: --force |