To foster automation between systems, integrate Snyk API & Web with GitHub Actions and trigger target scans from your GitHub.
First, you can start by reading about the Snyk API & Web Target Scan action in the GitHub marketplace to understand it in more detail and, especially, some preparation steps around Snyk API & Web. After that, the integration itself involves these two steps:
Get integration information from Snyk API & Web.
Configure GitHub to integrate with Snyk API & Web.
This article describes these steps in detail.
Step 1: Get integration information from Snyk API & Web
Before configuring the integration in GitHub, get the necessary information from Snyk API & Web:
Get the Target Identifier:
Go to the Targets menu entry in the Snyk API & Web app.
Click on the target and obtain the target identifier (target ID) from the URL.
Generate the API Key and save it to configure GitHub to be able to do actions in Snyk API & Web. Learn how to generate an API Key.
Step 2: Configure GitHub to integrate with Snyk API & Web
With the information from Snyk API & Web, it is time to do the configuration in GitHub:
Log in to the GitHub account and select the desired repository.
Go to the Settings tab, expand Secrets and variables, and click on Actions.
Click on New repository secret to add a secret with the value of the API Key to access Snyk API & Web.
Fill out the form fields:Set the Name with “PROBELY_API_KEY”.
In the field Secret, put the API Key generated in Step 1: Get the integration information from Snyk API & Web.
Now, go to the Actions tab and click on New workflow.
Click on the link set up a workflow yourself to open the form to configure the workflow:
At the top, type “probely.yml” for the filename.
Copy the code below and paste it to the editor of the workflow.
# Sample workflow for scanning a target with Probely
name: Scan a target with Probely
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
scan:
runs-on: ubuntu-latest
steps:
- name: Scan with Probely
id: probely-scan
uses: Probely/probely-github-action@main
with:
api-key: ${{ secrets.PROBELY_API_KEY }}
target-id: "<TARGET_ID>"
region: "eu"Replace <TARGET_ID> with the target identifier obtained in Step 1: Get the integration information from Snyk API & Web.
Take note of the name of the workflow: “Scan a target in Probely".
Click on Commit changes… to create the workflow.
The workflow starts automatically if the changes are committed to the main branch. Otherwise, if working in another branch, run the workflow as follows:
From now on, every time there’s a push to main, it triggers the scan of the target with Snyk API & Web.