|
| 1 | +name: Savant Smart Contract Analyzer |
| 2 | +# |
| 3 | +# Required secrets: |
| 4 | +# - SAVANT_API_TOKEN: API token for Savant.Chat (get from https://savant.chat -> Profile -> Settings -> API Keys) |
| 5 | +# |
| 6 | +# Optional secrets: |
| 7 | +# - SAVANT_NOTIFICATION_CONTACTS: Default notification contacts (comma-separated emails, Telegram usernames, or chat IDs) |
| 8 | +# These contacts will always receive notifications, regardless of trigger type. |
| 9 | +# Example: 'devops@company.com, @telegram_devops, 123456789' |
| 10 | +# |
| 11 | +on: |
| 12 | + # Manual trigger with inputs |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + base_commit: |
| 16 | + description: 'Base commit SHA for comparison' |
| 17 | + required: true |
| 18 | + head_commit: |
| 19 | + description: 'Head commit SHA for comparison' |
| 20 | + required: true |
| 21 | + default: 'HEAD' |
| 22 | + dry_run: |
| 23 | + description: 'Dry run mode' |
| 24 | + required: false |
| 25 | + default: 'false' |
| 26 | + type: boolean |
| 27 | + tier: |
| 28 | + description: 'Audit tier' |
| 29 | + required: false |
| 30 | + default: 'pro' |
| 31 | + type: choice |
| 32 | + options: |
| 33 | + - pro |
| 34 | + - advanced |
| 35 | + - lite |
| 36 | + notification_contacts: |
| 37 | + description: 'Additional notification contacts (comma-separated emails and Telegram usernames). Will be combined with SAVANT_NOTIFICATION_CONTACTS secret if set.' |
| 38 | + required: false |
| 39 | + default: '' |
| 40 | + |
| 41 | + # Automatically trigger on pull requests |
| 42 | + # pull_request: |
| 43 | + # branches: |
| 44 | + # - master |
| 45 | + # - main |
| 46 | + |
| 47 | + # Trigger on push to specified branches |
| 48 | + # push: |
| 49 | + # branches: |
| 50 | + # - master |
| 51 | + # - main |
| 52 | + |
| 53 | +jobs: |
| 54 | + analyze: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: Checkout code |
| 58 | + uses: actions/checkout@v3 |
| 59 | + with: |
| 60 | + fetch-depth: 0 |
| 61 | + |
| 62 | + - name: Combine notification contacts |
| 63 | + id: notification_contacts |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + SECRET_CONTACTS="${{ secrets.SAVANT_NOTIFICATION_CONTACTS }}" |
| 67 | + INPUT_CONTACTS="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.notification_contacts || '' }}" |
| 68 | + |
| 69 | + # Combine contacts if both exist, otherwise use whichever is available |
| 70 | + if [ -n "$SECRET_CONTACTS" ] && [ -n "$INPUT_CONTACTS" ]; then |
| 71 | + COMBINED_CONTACTS="${SECRET_CONTACTS}, ${INPUT_CONTACTS}" |
| 72 | + elif [ -n "$SECRET_CONTACTS" ]; then |
| 73 | + COMBINED_CONTACTS="$SECRET_CONTACTS" |
| 74 | + elif [ -n "$INPUT_CONTACTS" ]; then |
| 75 | + COMBINED_CONTACTS="$INPUT_CONTACTS" |
| 76 | + else |
| 77 | + COMBINED_CONTACTS="" |
| 78 | + fi |
| 79 | + |
| 80 | + echo "contacts=$COMBINED_CONTACTS" >> $GITHUB_OUTPUT |
| 81 | + echo "Combined notification contacts: $COMBINED_CONTACTS" |
| 82 | + |
| 83 | + - name: Create Savant.Chat audit request |
| 84 | + uses: auditdbio/savant-smart-contract-analyzer@v1.4 |
| 85 | + with: |
| 86 | + base_commit: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.base_commit || github.event_name == 'push' && github.event.before || github.event.pull_request.base.sha }} |
| 87 | + head_commit: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.head_commit || github.event_name == 'push' && github.sha || github.event.pull_request.head.sha }} |
| 88 | + api_token: ${{ secrets.SAVANT_API_TOKEN }} |
| 89 | + dry_run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run || 'false' }} |
| 90 | + tier: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tier || 'advanced' }} |
| 91 | + notification_contacts: ${{ steps.notification_contacts.outputs.contacts }} |
| 92 | + |
0 commit comments