-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Update CB01 URL | ||
|
||
on: | ||
schedule: | ||
# Run every day at 6:00 AM CET (5:00 AM UTC) | ||
- cron: "0 5 * * *" | ||
workflow_dispatch: # Allows manual triggering | ||
|
||
jobs: | ||
update-main-url: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
# Find the redirected URL and update the file | ||
- name: Update mainUrl | ||
run: | | ||
# Define the file path | ||
FILE_PATH="CB01/src/main/kotlin/it/dogior/hadEnough/CB01.kt" | ||
# Ensure the file exists | ||
if [ ! -f "$FILE_PATH" ]; then | ||
echo "File $FILE_PATH not found!" | ||
exit 1 | ||
fi | ||
# Perform the request and extract the redirected URL | ||
REDIRECTED_URL=$(curl -Ls -o /dev/null -w %{url_effective} "https://cb01.uno") | ||
if [ -z "$REDIRECTED_URL" ]; then | ||
echo "Failed to retrieve the redirected URL!" | ||
exit 1 | ||
fi | ||
echo "Redirected URL: $REDIRECTED_URL" | ||
# Replace the mainUrl value in the file | ||
sed -i "s|override var mainUrl = .*|override var mainUrl = \"$REDIRECTED_URL\"|" "$FILE_PATH" | ||
# Display the updated file for debugging | ||
echo "Updated file content:" | ||
cat "$FILE_PATH" | ||
# Commit and push the changes | ||
- name: Commit and Push Changes | ||
run: | | ||
git config user.name "GitHub Actions Bot" | ||
git config user.email "[email protected]" | ||
git add CB01/src/main/kotlin/it/dogior/hadEnough/CB01.kt | ||
git commit -m "Update url" | ||
git push |