Use last state attribute #88
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 and Lint | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
permissions: | |
contents: write | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
if: github.actor != 'github-actions[bot]' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install black isort | |
- name: Run Black and isort | |
run: | | |
black custom_components/sensus_analytics | |
isort custom_components/sensus_analytics | |
- name: Commit changes | |
id: commit_changes | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add -A | |
if git commit -m "Auto-format code with Black and isort"; then | |
echo "changes=true" >> $GITHUB_OUTPUT | |
else | |
echo "changes=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Determine Branch to Push | |
id: determine_branch | |
run: | | |
if [ "${{ github.event_name }}" = "pull_request" ]; then | |
echo "branch=${GITHUB_HEAD_REF}" >> $GITHUB_OUTPUT | |
else | |
BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
echo "branch=${BRANCH_NAME}" >> $GITHUB_OUTPUT | |
fi # Added 'fi' to close the if statement | |
- name: Push changes | |
if: steps.commit_changes.outputs.changes == 'true' | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ steps.determine_branch.outputs.branch }} | |
lint: | |
needs: format | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.12"] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install bandit pylint | |
pip install -r requirements.txt | |
- name: Run Bandit Security Linter | |
run: bandit -r custom_components/sensus_analytics | |
- name: Run Pylint | |
run: pylint custom_components/sensus_analytics |