1- name : Check for issues with signing certificates
1+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-certificates.md
2+ name : Check Certificates
23
4+ # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
35on :
6+ push :
7+ paths :
8+ - " .github/workflows/check-certificates.ya?ml"
9+ pull_request :
10+ paths :
11+ - " .github/workflows/check-certificates.ya?ml"
412 schedule :
5- # run every 10 hours
13+ # Run every 10 hours.
614 - cron : " 0 */10 * * *"
7- # workflow_dispatch event allows the workflow to be triggered manually.
8- # This could be used to run an immediate check after updating certificate secrets.
9- # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
1015 workflow_dispatch :
16+ repository_dispatch :
1117
1218env :
13- # Begin notifications when there are less than this many days remaining before expiration
19+ # Begin notifications when there are less than this many days remaining before expiration.
1420 EXPIRATION_WARNING_PERIOD : 30
1521
1622jobs :
1723 check-certificates :
18- # This workflow would fail in forks that don't have the certificate secrets defined
19- if : github.repository == 'arduino/arduino-cli'
24+ name : ${{ matrix.certificate.identifier }}
25+ # Only run when the workflow will have access to the certificate secrets.
26+ if : >
27+ (github.event_name != 'pull_request' && github.repository == 'arduino/arduino-cli') ||
28+ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'arduino/arduino-cli')
2029 runs-on : ubuntu-latest
21-
2230 strategy :
2331 fail-fast : false
2432
2533 matrix :
2634 certificate :
27- - identifier : macOS signing certificate # Text used to identify the certificate in notifications
28- certificate-secret : INSTALLER_CERT_MAC_P12 # The name of the secret that contains the certificate
29- password-secret : INSTALLER_CERT_MAC_PASSWORD # The name of the secret that contains the certificate password
35+ # Additional certificate definitions can be added to this list.
36+ - identifier : macOS signing certificate # Text used to identify certificate in notifications.
37+ certificate-secret : INSTALLER_CERT_MAC_P12 # Name of the secret that contains the certificate.
38+ password-secret : INSTALLER_CERT_MAC_PASSWORD # Name of the secret that contains the certificate password.
3039
3140 steps :
3241 - name : Set certificate path environment variable
3342 run : |
34- # See: https://docs.github.com/en/free-pro-team@latest/ actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
43+ # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
3544 echo "CERTIFICATE_PATH=${{ runner.temp }}/certificate.p12" >> "$GITHUB_ENV"
3645
3746 - name : Decode certificate
@@ -53,18 +62,17 @@ jobs:
5362 exit 1
5463 )
5564
56- # See: https://github.com/rtCamp/action-slack-notify
5765 - name : Slack notification of certificate verification failure
5866 if : failure()
59- uses : rtCamp/action-slack-notify@v2.2.0
6067 env :
61- SLACK_WEBHOOK : ${{ secrets.TEAM_TOOLING_CHANNEL_SLACK_WEBHOOK }}
68+ SLACK_WEBHOOK : ${{ secrets.SLACK_WEBHOOK }}
6269 SLACK_MESSAGE : |
6370 :warning::warning::warning::warning:
6471 WARNING: ${{ github.repository }} ${{ matrix.certificate.identifier }} verification failed!!!
6572 :warning::warning::warning::warning:
6673 SLACK_COLOR : danger
6774 MSG_MINIMAL : true
75+ uses : rtCamp/action-slack-notify@v2
6876
6977 - name : Get days remaining before certificate expiration date
7078 env :
93101
94102 DAYS_BEFORE_EXPIRATION="$((($(date --utc --date="$EXPIRATION_DATE" +%s) - $(date --utc +%s)) / 60 / 60 / 24))"
95103
96- # Display the expiration information in the log
104+ # Display the expiration information in the log.
97105 echo "Certificate expiration date: $EXPIRATION_DATE"
98106 echo "Days remaining before expiration: $DAYS_BEFORE_EXPIRATION"
99107
@@ -108,14 +116,14 @@ jobs:
108116 fi
109117
110118 - name : Slack notification of pending certificate expiration
111- # Don't send spurious expiration notification if verification fails
119+ # Don't send spurious expiration notification if verification fails.
112120 if : failure() && steps.check-expiration.outcome == 'failure'
113- uses : rtCamp/action-slack-notify@v2.2.0
114121 env :
115- SLACK_WEBHOOK : ${{ secrets.TEAM_TOOLING_CHANNEL_SLACK_WEBHOOK }}
122+ SLACK_WEBHOOK : ${{ secrets.SLACK_WEBHOOK }}
116123 SLACK_MESSAGE : |
117124 :warning::warning::warning::warning:
118125 WARNING: ${{ github.repository }} ${{ matrix.certificate.identifier }} will expire in ${{ steps.get-days-before-expiration.outputs.days }} days!!!
119126 :warning::warning::warning::warning:
120127 SLACK_COLOR : danger
121128 MSG_MINIMAL : true
129+ uses : rtCamp/action-slack-notify@v2
0 commit comments