1111 schedule :
1212 # At 05:00 AM, every 365 days, only in January (UTC)
1313 - cron : " 0 5 */365 1 *"
14+
1415jobs :
16+ verify-tokens :
17+ name : " Verify tokens"
18+ runs-on : ubuntu-latest
19+ timeout-minutes : 10
20+ if : " ${{ github.event_name == 'push' }}"
21+ outputs :
22+ codacy-token-set : " ${{ steps.check-tokens.outputs.CODACY_TOKEN_SET }}"
23+ sonar-token-set : " ${{ steps.check-tokens.outputs.SONAR_TOKEN_SET }}"
24+ steps :
25+ - name : " Verify tokens"
26+ id : check-tokens
27+ run : |
28+ # Verifying tokens...
29+ # Codacy
30+ if test -n '${{ secrets.CODACY_PROJECT_TOKEN }}'; then token_set='true'; else token_set='false'; fi
31+ printf 'CODACY_TOKEN_SET=%s\n' "${token_set:?}" 1>> "${GITHUB_OUTPUT?}"
32+ # SonarQube
33+ if test -n '${{ secrets.SONAR_TOKEN }}'; then token_set='true'; else token_set='false'; fi
34+ printf 'SONAR_TOKEN_SET=%s\n' "${token_set:?}" 1>> "${GITHUB_OUTPUT?}"
35+
1536 codacy :
1637 name : " Codacy"
38+ needs : [verify-tokens]
1739 runs-on : ubuntu-latest
18- if : " ${{ github.event_name == 'push' }}"
40+ timeout-minutes : 20
41+ if : " ${{ github.event_name == 'push' && needs.verify-tokens.outputs.codacy-token-set == 'true' }}"
1942 concurrency :
2043 group : " ${{ github.repository_id }}-${{ github.workflow }}-codacy"
2144 cancel-in-progress : false
2245 permissions :
2346 security-events : write
2447
2548 steps :
26- - name : " Verify token"
27- shell : bash
28- run : |
29- # Verifying token...
30- test -n '${{ secrets.CODACY_PROJECT_TOKEN }}' || exit 3
3149 - name : " Checkout sources"
3250 uses : actions/checkout@v4
3351 - name : " Codacy analysis"
3452 uses : codacy/codacy-analysis-cli-action@v4
53+ timeout-minutes : 10
3554 with :
3655 project-token : " ${{ secrets.CODACY_PROJECT_TOKEN }}"
3756 # verbose: true
@@ -55,20 +74,18 @@ jobs:
5574
5675 sonarqube :
5776 name : " SonarQube"
77+ needs : [verify-tokens]
5878 runs-on : ubuntu-latest
59- if : " ${{ github.event_name == 'push' }}"
79+ timeout-minutes : 20
80+ if : " ${{ github.event_name == 'push' && needs.verify-tokens.outputs.sonar-token-set == 'true' }}"
6081
6182 steps :
62- - name : " Verify token"
63- shell : bash
64- run : |
65- # Verifying token...
66- test -n '${{ secrets.SONAR_TOKEN }}' || exit 3
6783 - name : " Checkout sources"
6884 uses : actions/checkout@v4
6985 with :
7086 fetch-depth : " 0" # Shallow clones should be disabled for a better relevancy of analysis
7187 - name : " SonarQube scan"
7288 uses : SonarSource/sonarqube-scan-action@v5
89+ timeout-minutes : 10
7390 env :
7491 SONAR_TOKEN : " ${{ secrets.SONAR_TOKEN }}"
0 commit comments