Skip to content

Token Expiration

Token Expiration #449

Workflow file for this run

# Copyright IBM Corp. 2019, 2026
# "SPDX-License-Identifier: MPL-2.0"
name: Token Expiration
on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
check_token_expiration:
name: Check
runs-on: ubuntu-latest
steps:
- name: Check token expiration
run: |
# Set the expiration date of the token
TOKEN_EXPIRATION_DATE="2025-12-01"
# Get the current date
CURRENT_DATE=$(date -u +"%Y-%m-%d")
# Calculate the difference in days between the current date and the expiration date
DAYS_LEFT=$(( ( $(date -ud "$TOKEN_EXPIRATION_DATE" +'%s') - $(date -ud "$CURRENT_DATE" +'%s') )/(60*60*24) ))
# If the token expires in less than 7 days, create an issue
if [ "$DAYS_LEFT" -le 7 ]; then
echo "Token expires in $DAYS_LEFT days. Creating an issue..."
ISSUE_TITLE="YAKBOT_GITHUB_TOKEN Expiration Alert"
ISSUE_BODY="The YAKBOT_GITHUB_TOKEN will expire on $TOKEN_EXPIRATION_DATE. Please renew the token."
curl -X POST -H "Authorization: token ${{ secrets.BEEFY_TOKEN }}" \
-d "{\"title\":\"$ISSUE_TITLE\",\"body\":\"$ISSUE_BODY\"}" \
https://api.github.com/repos/${{ github.repository }}/issues
else
echo "Token is valid for $DAYS_LEFT more days."
fi