Skip to content

Add cost calculations #3

Add cost calculations

Add cost calculations #3

Workflow file for this run

name: Format Code
on:
push:
branches:
- main
pull_request:
permissions:
contents: write
jobs:
format:
runs-on: ubuntu-latest
if: github.actor != 'github-actions[bot]' # Prevents infinite loop
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetches full history to push changes
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12' # Adjust to your Python version
- 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
# Remove 'refs/heads/' prefix
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 }}