1+ name : SecurityChecks
2+ on :
3+ pull_request : {}
4+ push :
5+ branches : ["master"]
6+ schedule :
7+ - cron : ' 30 20 * * *'
8+ jobs :
9+ semgrep :
10+ name : Scan
11+ runs-on : [ubuntu-latest] # nosemgrep : semgrep.dev/s/swati31196:github_provided_runner
12+ steps :
13+ - uses : actions/checkout@v2
14+ - uses : returntocorp/semgrep-action@v1
15+ with :
16+ publishToken : ${{ secrets.SEMGREP_APP_TOKEN }}
17+ publishDeployment : 339
18+ env :
19+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
20+
21+ workflow_status :
22+ runs-on : [ ubuntu-latest ] # nosemgrep : semgrep.dev/s/swati31196:github_provided_runner
23+ name : Update Status Check
24+ needs : [ semgrep ]
25+ if : always()
26+ env :
27+ githubCommit : ${{ github.event.pull_request.head.sha }}
28+ steps :
29+ - name : Set github commit id
30+ run : |
31+ if [ "${{ github.event_name }}" = "push" ] || [ "${{ github.event_name }}" = "schedule" ]; then
32+ echo "githubCommit=${{ github.sha }}" >> $GITHUB_ENV
33+ fi
34+ exit 0
35+ - name : Failed
36+ id : failed
37+ if : (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && github.ref != 'refs/heads/master'
38+ run : |
39+ echo 'Failing the workflow for github security status check.'
40+ curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
41+ -d '{ "state" : "failure" , "context" : "github/security-status-check" , "description" : "github/security-status-check", "target_url" : "https://github.com/${{ github.repository }}" }' \
42+ https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.githubCommit }}
43+ exit 1
44+ - name : Success
45+ if : steps.failed.conclusion == 'skipped' || github.ref != 'refs/heads/master'
46+ run : |
47+ echo 'Status check has passed!'
48+ curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
49+ -d '{ "state" : "success" , "context" : "github/security-status-check" , "description" : "github/security-status-check", "target_url" : "https://github.com/${{ github.repository }}" }' \
50+ https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.githubCommit }}
51+ exit 0
0 commit comments