add python setup to version bump action #1
This file contains hidden or 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
| on: | |
| push: | |
| branches: | |
| - main # Splitting out main here ensures we do not redundantly run this workflow on merge from a PR | |
| pull_request: | |
| branches: | |
| - "*" # Match all branches | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| fmt: | |
| if: ${{ github.actor != 'panther-bot-automation' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
| - name: Setup Python | |
| uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b | |
| with: | |
| python-version: 3.11 | |
| - name: Install poetry | |
| run: make install-poetry | |
| - name: Install | |
| run: make install | |
| - name: Format | |
| run: make fmt | |
| - name: Import GPG key | |
| uses: crazy-max/ghaction-import-gpg@v6 | |
| with: | |
| gpg_private_key: ${{ secrets.PANTHER_BOT_GPG_PRIVATE_KEY }} | |
| passphrase: ${{ secrets.PANTHER_BOT_GPG_PRIVATE_KEY_PASSPHRASE }} | |
| git_user_signingkey: true | |
| git_commit_gpgsign: true | |
| - name: Commit formatting | |
| run: | | |
| git config --global user.name "panther-bot-automation" | |
| git config --global user.email "[email protected]" | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| BRANCH=${{ github.head_ref }} | |
| git fetch; git checkout ${{ github.head_ref }} | |
| else | |
| BRANCH=${{ github.ref }} | |
| fi | |
| git add -A . | |
| REQUIRES_COMMIT=1 | |
| git commit -S -m "Auto-format files" || REQUIRES_COMMIT=0 | |
| if [[ $REQUIRES_COMMIT -eq 0 ]]; then | |
| echo "No auto-formatting needed" | |
| else | |
| echo "Committing auto-formatted files" | |
| git push origin HEAD:$BRANCH | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.PANTHER_BOT_AUTOMATION_TOKEN }} |