GitHub Actions
GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and test every pull request to your repository, or deploy merged pull requests to production.
This how-to will provide a basic understanding of how add the Relyance Source Code inspector (SCI) into a typical build job.
Prerequisites:
- A source code repository needs to be available.
- The
relyance.yamlfile needs to be in the source code root directory. - Follow Set up SCI to create an OAuth credential and copy the Docker command from Step 2. Set the Actions repository variable
SCI_IMAGEto the full image reference shown at the end of that command.
See more info about the SCI commands here.
Steps:
- Login to your GitHub account.
- Navigate to the main page of the repository.
- Ensure your source code repository has the preconfigured
relyance.yamlfile in the root path of your source code. - Create a secret in Github:
- Click on the Settings tab in the repo header.
- Click on Secrets and variables> Actions.
- Create a New repository secret.
- Set the name to RELYANCE_API_KEY and paste the full
API_KEYvalue you copied when you created the OAuth credential.
- Navigate to the main page of the repository.
- In the header tabs, click Actions.
- Click on the set up a workflow yourself link (or create a new workflow under .github/workflows/).
- Using the template below, update the workflow:
name: Relyance SCI Scan
on:
#TODO: Modify the cron job schedule below.
schedule:
- cron: "0 20 * * *"
workflow_dispatch:
jobs:
#TODO: Modify the job names and the machine below if you would like.
execute-relyance-sci:
name: Relyance SCI Job
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run SCI
env:
API_KEY: ${{ secrets.RELYANCE_API_KEY }}
SCI_IMAGE: ${{ vars.SCI_IMAGE }}
run: |-
docker run --pull=always --rm --env API_KEY --volume "$PWD:/repo:ro" "$SCI_IMAGE"Note: The workflow_dispatch command allows you to manually run the SCI scan, this can be removed.
9. Commit changes.
10. This job will now run according to the scheduled CRON job in GitHub actions.
If you wish to run the action manually and have the workflow_dispatch command in the Action file:
- Go back to the Actions tab after you've committed the file.
- In the left-side menu click the Relyance SCI Scan link.
- Click the Run workflow button and run the workflow.
- Once complete, you should see:
- If there are no errors, you should start to see SCI results in your Relyance tenant.
Appendix:
Run the command from the repository root with the scan job's API_KEY environment variable and the image from Step 2.
docker run --pull=always --rm --env API_KEY --volume "$PWD:/repo:ro" "$SCI_IMAGE"