GitHub Actions | Safety Documentation (original) (raw)

  1. Integration
  2. Securing Git Repositories
  3. GitHub

GitHub Actions

Introduction to GitHub Actions

GitHub Actions is a powerful automation tool that integrates directly with GitHub repositories to allow you to automate your workflow by setting up a series of commands (actions) that execute in response to specific GitHub events like a push or a pull request. These actions can be used for a variety of tasks, such as testing code, deploying applications and, in the case of Safety, scanning for vulnerabilities.

The Safety CLI Scanner GitHub Action enables automated scanning of your projects for vulnerabilities directly within your GitHub workflow.

Link to Safety GitHub Action: https://github.com/marketplace/actions/pyupio-safety-action

Setting Up the Safety GitHub Action

Step 1: Create a Safety Account and Obtain an API Key

Organization and User API Keys are available in Organization->API Keys

Step 2: Configure the GitHub Secret

Add a new Secret to your Repo called SAFETY_API_KEY

Step 3: Set Up the Workflow File

name: Example workflow for Python using Safety Action
on: push
jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main
      - name: Run Safety CLI to check for vulnerabilities
        uses: pyupio/safety-action@v1
        with:
          api-key: ${{ secrets.SAFETY_API_KEY }}

Step 4: Activate the Workflow

Additional Configurations (Optional)

name: Example workflow customizing the Safety Action
on: push
jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@main
      - name: Run Safety CLI to check for vulnerabilities
        uses: pyupio/safety-action@v1
        with:
          api-key: ${{ secrets.SAFETY_API_KEY }}
          args: --detailed-output # To always see detailed output from this action

Options are: screen, json, html, spdx, none

Override the default arguments to Safety CLI 3.

For more detailed information about Safety's CLI and its functionalities, please refer to Safety 3 Documentation or contact our Support Team.

Last updated 7 months ago