Skip to content

Fossa License Scan #1337

Fossa License Scan

Fossa License Scan #1337

Workflow file for this run

# This workflow scans the licenses with Fossa and waits until the license test finished
name: Fossa License Scan
on:
workflow_run:
workflows:
- Push Workflow Trigger
types:
- completed
jobs:
fossa-license-analyze:
name: "Fossa ${{ github.event.workflow_run.head_branch != 'master' && format('PR {0}', github.event.workflow_run.pull_requests[0].number) || 'master' }}"
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Initiate check
env:
SHA: "${{ github.event.workflow_run.head_sha }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: >-
gh api
--method POST
-H "Accept: application/vnd.github+json"
/repos/SDA-SE/mongodb-operator/statuses/${SHA}
-f state='pending'
-f target_url=https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
-f description='Checking Licenses'
-f context='fossa-license-analyze'
continue-on-error: true
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
with:
ref: ${{ github.event.workflow_run.head_sha }} # checkout commit that triggered this workflow
- name: Set up JDK
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
distribution: 'temurin'
java-version: 21
cache: 'gradle'
- name: Install Fossa
run: "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/v3.2.8/install-latest.sh | sudo bash"
- name: Fossa Analyze
env:
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
BRANCH: ${{ github.event.workflow_run.head_branch }}
run: fossa analyze --project "mongodb-operator" --branch "$BRANCH"
- name: Fossa Test
env:
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
run: fossa test --project "mongodb-operator" --debug
- name: Successful check
if: success()
env:
SHA: "${{ github.event.workflow_run.head_sha }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: >-
gh api
--method POST
-H "Accept: application/vnd.github+json"
/repos/SDA-SE/mongodb-operator/statuses/${SHA}
-f state='success'
-f target_url=https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
-f description='License approved'
-f context='fossa-license-analyze'
continue-on-error: true
- name: Failed check
if: failure()
env:
SHA: "${{ github.event.workflow_run.head_sha }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: >-
gh api
--method POST
-H "Accept: application/vnd.github+json"
/repos/SDA-SE/mongodb-operator/statuses/${SHA}
-f state='failure'
-f target_url=https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
-f description='License check failed'
-f context='fossa-license-analyze'
continue-on-error: true