Skip to content

Commit 06d44af

Browse files
authored
Merge pull request #212 from per1234/update-check-certificate
Sync "Check Certificates" CI workflow with template
2 parents 6edad11 + 137ed3a commit 06d44af

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

.github/workflows/check-certificates.yml

+27-20
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,46 @@
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
35
on:
46
push:
7+
paths:
8+
- ".github/workflows/check-certificates.ya?ml"
9+
pull_request:
10+
paths:
11+
- ".github/workflows/check-certificates.ya?ml"
512
schedule:
6-
# run every 10 hours
13+
# Run every 10 hours.
714
- cron: "0 */10 * * *"
8-
# workflow_dispatch event allows the workflow to be triggered manually.
9-
# This could be used to run an immediate check after updating certificate secrets.
10-
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
1115
workflow_dispatch:
16+
repository_dispatch:
1217

1318
env:
14-
# 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.
1520
EXPIRATION_WARNING_PERIOD: 30
1621

1722
jobs:
1823
check-certificates:
19-
# This workflow would always fail in forks
20-
if: github.repository == 'arduino/arduino-lint'
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-lint') ||
28+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'arduino/arduino-lint')
2129
runs-on: ubuntu-latest
22-
2330
strategy:
2431
fail-fast: false
2532

2633
matrix:
2734
certificate:
28-
- identifier: macOS signing certificate # Text used to identify the certificate in notifications
29-
certificate-secret: INSTALLER_CERT_MAC_P12 # The name of the secret that contains the certificate
30-
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.
3139

3240
steps:
3341
- name: Set certificate path environment variable
3442
run: |
35-
# 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
3644
echo "CERTIFICATE_PATH=${{ runner.temp }}/certificate.p12" >> "$GITHUB_ENV"
3745
3846
- name: Decode certificate
@@ -54,18 +62,17 @@ jobs:
5462
exit 1
5563
)
5664
57-
# See: https://github.com/rtCamp/action-slack-notify
5865
- name: Slack notification of certificate verification failure
5966
if: failure()
60-
uses: rtCamp/action-slack-notify@v2
6167
env:
62-
SLACK_WEBHOOK: ${{ secrets.TEAM_TOOLING_CHANNEL_SLACK_WEBHOOK }}
68+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
6369
SLACK_MESSAGE: |
6470
:warning::warning::warning::warning:
6571
WARNING: ${{ github.repository }} ${{ matrix.certificate.identifier }} verification failed!!!
6672
:warning::warning::warning::warning:
6773
SLACK_COLOR: danger
6874
MSG_MINIMAL: true
75+
uses: rtCamp/action-slack-notify@v2
6976

7077
- name: Get days remaining before certificate expiration date
7178
env:
@@ -94,7 +101,7 @@ jobs:
94101
95102
DAYS_BEFORE_EXPIRATION="$((($(date --utc --date="$EXPIRATION_DATE" +%s) - $(date --utc +%s)) / 60 / 60 / 24))"
96103
97-
# Display the expiration information in the log
104+
# Display the expiration information in the log.
98105
echo "Certificate expiration date: $EXPIRATION_DATE"
99106
echo "Days remaining before expiration: $DAYS_BEFORE_EXPIRATION"
100107
@@ -109,14 +116,14 @@ jobs:
109116
fi
110117
111118
- name: Slack notification of pending certificate expiration
112-
# Don't send spurious expiration notification if verification fails
119+
# Don't send spurious expiration notification if verification fails.
113120
if: failure() && steps.check-expiration.outcome == 'failure'
114-
uses: rtCamp/action-slack-notify@v2
115121
env:
116-
SLACK_WEBHOOK: ${{ secrets.TEAM_TOOLING_CHANNEL_SLACK_WEBHOOK }}
122+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
117123
SLACK_MESSAGE: |
118124
:warning::warning::warning::warning:
119125
WARNING: ${{ github.repository }} ${{ matrix.certificate.identifier }} will expire in ${{ steps.get-days-before-expiration.outputs.days }} days!!!
120126
:warning::warning::warning::warning:
121127
SLACK_COLOR: danger
122128
MSG_MINIMAL: true
129+
uses: rtCamp/action-slack-notify@v2

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![Nightly Status](https://github.com/arduino/arduino-lint/workflows/Nightly%20build/badge.svg)](https://github.com/arduino/arduino-lint/actions?workflow=Nightly+build)
55
[![Docs Status](https://github.com/arduino/arduino-lint/workflows/Publish%20documentation/badge.svg)](https://github.com/arduino/arduino-lint/actions?workflow=Publish+documentation)
66
[![Codecov](https://codecov.io/gh/arduino/arduino-lint/branch/main/graph/badge.svg?token=nprqPQMbdh)](https://codecov.io/gh/arduino/arduino-lint)
7+
[![Check Certificates status](https://github.com/arduino/arduino-lint/actions/workflows/check-certificates.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-certificates.yml)
78

89
**Arduino Lint** is a command line tool that checks for common problems in [Arduino](https://www.arduino.cc/) projects:
910

0 commit comments

Comments
 (0)