Skip to content

Commit 1678e4e

Browse files
updated content package version check script (#10455)
Co-authored-by: harishsundar-okta <harishsundar-okta>
1 parent c6dd261 commit 1678e4e

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Check Content Version
2+
3+
on:
4+
schedule:
5+
- cron: '0 * * * *' # Runs every hour
6+
workflow_dispatch: # Allows manual trigger from GitHub Actions tab
7+
8+
jobs:
9+
run-script:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: Make script executable
17+
run: chmod +x scripts/check-version.sh
18+
shell: bash
19+
20+
- name: Run check-version.sh script
21+
run: scripts/check-version.sh
22+
shell: bash

scripts/check-version.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# URL of the webpage
4+
URL="https://auth0.com/docs"
5+
6+
# Slack webhook URL
7+
WEBHOOK_URL="https://hooks.slack.com/triggers/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"
8+
9+
# Function to send Slack notification with the version as a data variable
10+
send_slack_notification() {
11+
local version="$1"
12+
curl -s -X POST -H 'Content-type: application/json' --data "{
13+
\"version\": \"${version}\"
14+
}" "$WEBHOOK_URL"
15+
}
16+
17+
# Directory to store the current version file
18+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19+
VERSION_FILE="${SCRIPT_DIR}/tmp/current_version.txt"
20+
21+
# Ensure the tmp directory exists
22+
mkdir -p "${SCRIPT_DIR}/tmp"
23+
24+
# Read the current version from the file, if it exists
25+
if [ -f "$VERSION_FILE" ]; then
26+
current_version=$(cat "$VERSION_FILE")
27+
else
28+
current_version=""
29+
fi
30+
31+
# Bypass cache by using cache-control headers and appending a unique query string
32+
cache_bypass=$(date +%s)
33+
response=$(curl -s -H "Cache-Control: no-cache, no-store, must-revalidate" \
34+
-H "Pragma: no-cache" \
35+
-H "Expires: 0" \
36+
"${URL}?nocache=${cache_bypass}")
37+
38+
# Print the response for debugging
39+
echo "Response from URL: $response"
40+
41+
# Extract the new version from the response
42+
new_version=$(echo "$response" | sed -n 's/.*"CONTENT_PACKAGE_VERSION":"\([^"]*\)".*/\1/p')
43+
44+
# Print the new version for debugging
45+
echo "Extracted new version: $new_version"
46+
47+
# Compare with stored version
48+
if [ "$new_version" != "$current_version" ]; then
49+
echo "Package version updated: $new_version"
50+
# Send Slack notification with the version
51+
send_slack_notification "$new_version"
52+
# Update the current version in the file
53+
echo "$new_version" > "$VERSION_FILE"
54+
else
55+
echo "Package version has not changed."
56+
fi

0 commit comments

Comments
 (0)