Update README.rdoc #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: FOSSA CLI Analysis | |
on: | |
push: | |
branches: [ $default-branch ] | |
pull_request: | |
branches: [ $default-branch ] | |
workflow_dispatch: | |
jobs: | |
fossa: | |
runs-on: ubuntu-latest | |
env: | |
FOSSA_API_KEY: ${{secrets.FOSSA_API_KEY}} | |
ORG: ${{ github.repository_owner }} | |
REPO: ${{ github.repository }} | |
ORG_ADMIN_PAT: ${{ secrets.ELAGUERTA_PAT }} | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
- id: fossa-list-targets | |
name: Run fossa list-targets | |
run: | | |
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash | |
list_targets_output=$(set -e; fossa list-targets 2>&1) | |
printf -- "%s\n" "$list_targets_output" | |
if [[ $(echo $list_targets_output | grep "Error" | wc -l) -gt 0 ]] | |
then | |
"HAS_FOSSA_TARGETS=Error" >> "$GITHUB_OUTPUT" | |
elif [[ $(echo $list_targets_output | grep "Found target" | wc -l) -gt 0 ]] | |
then | |
fossa analyze | |
"HAS_FOSSA_TARGETS=True" >> "$GITHUB_OUTPUT" | |
else | |
printf -- "Fossa did not find any analysis targets.\n" | |
"HAS_FOSSA_TARGETS=False" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Set hasFossaTargets custom property | |
run: | | |
curl -L \ | |
-X PATCH \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer $ORG_ADMIN_PAT" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/orgs/$ORG/properties/values \ | |
-d '{"repository_names":["'"${REPO##*/}"'"],"properties":[{"property_name":"hasFossaTargets","value":"'"${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS }}"'"}]}' | |
- name: Fail if fossa list-targets had an error | |
if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'Error'}} | |
run: exit 1 | |
- name: Run fossa analyze | |
if: ${{ steps.fossa-list-targets.outputs.HAS_FOSSA_TARGETS == 'True'}} | |
run: fossa analyze | |