@@ -45,11 +45,13 @@ jobs:
45
45
run : |
46
46
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
47
47
echo "CERTIFICATE_PATH=${{ runner.temp }}/certificate.p12" >> "$GITHUB_ENV"
48
+
48
49
- name : Decode certificate
49
50
env :
50
51
CERTIFICATE : ${{ secrets[matrix.certificate.certificate-secret] }}
51
52
run : |
52
53
echo "${{ env.CERTIFICATE }}" | base64 --decode > "${{ env.CERTIFICATE_PATH }}"
54
+
53
55
- name : Verify certificate
54
56
env :
55
57
CERTIFICATE_PASSWORD : ${{ secrets[matrix.certificate.password-secret] }}
62
64
echo "::error::Verification of ${{ matrix.certificate.identifier }} failed!!!"
63
65
exit 1
64
66
)
67
+
65
68
- name : Slack notification of certificate verification failure
66
69
if : failure()
67
- uses : rtCamp/action-slack-notify@v2
68
70
env :
69
71
SLACK_WEBHOOK : ${{ secrets.TEAM_CREATE_CHANNEL_SLACK_WEBHOOK }}
70
72
SLACK_MESSAGE : |
73
75
:warning::warning::warning::warning:
74
76
SLACK_COLOR : danger
75
77
MSG_MINIMAL : true
78
+ uses : rtCamp/action-slack-notify@v2
76
79
77
80
- name : Get days remaining before certificate expiration date
78
81
env :
@@ -98,27 +101,32 @@ jobs:
98
101
'notAfter=(\K.*)'
99
102
)
100
103
)"
104
+
101
105
DAYS_BEFORE_EXPIRATION="$((($(date --utc --date="$EXPIRATION_DATE" +%s) - $(date --utc +%s)) / 60 / 60 / 24))"
106
+
102
107
# Display the expiration information in the log.
103
108
echo "Certificate expiration date: $EXPIRATION_DATE"
104
109
echo "Days remaining before expiration: $DAYS_BEFORE_EXPIRATION"
110
+
105
111
echo "::set-output name=days::$DAYS_BEFORE_EXPIRATION"
112
+
106
113
- name : Check if expiration notification period has been reached
107
114
id : check-expiration
108
115
run : |
109
116
if [[ ${{ steps.get-days-before-expiration.outputs.days }} -lt ${{ env.EXPIRATION_WARNING_PERIOD }} ]]; then
110
117
echo "::error::${{ matrix.certificate.identifier }} will expire in ${{ steps.get-days-before-expiration.outputs.days }} days!!!"
111
118
exit 1
112
119
fi
120
+
113
121
- name : Slack notification of pending certificate expiration
114
122
# Don't send spurious expiration notification if verification fails.
115
123
if : failure() && steps.check-expiration.outcome == 'failure'
116
- uses : rtCamp/action-slack-notify@v2
117
124
env :
118
125
SLACK_WEBHOOK : ${{ secrets.TEAM_CREATE_CHANNEL_SLACK_WEBHOOK }}
119
126
SLACK_MESSAGE : |
120
127
:warning::warning::warning::warning:
121
128
WARNING: ${{ github.repository }} ${{ matrix.certificate.identifier }} will expire in ${{ steps.get-days-before-expiration.outputs.days }} days!!!
122
129
:warning::warning::warning::warning:
123
130
SLACK_COLOR : danger
124
- MSG_MINIMAL : true
131
+ MSG_MINIMAL : true
132
+ uses : rtCamp/action-slack-notify@v2
0 commit comments