Fetch Tomcat Versions #23
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
name: Fetch Tomcat Versions | |
on: | |
schedule: | |
- cron: '* * * * *' # Runs at midnight on every 10th day of the month | |
jobs: | |
fetch_tomcat_versions: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Fetch latest Tomcat versions | |
run: | | |
MAJOR_VERSION=$(curl -s https://dlcdn.apache.org/tomcat/ | grep -oP 'tomcat-[0-9]+' | sort -V | tail -1 | grep -oP '[0-9]+') | |
LATEST_VERSION=$(curl -s https://dlcdn.apache.org/tomcat/tomcat-${MAJOR_VERSION}/ | grep -oP 'v\d+\.\d+\.\d+.*?/' | sort -V | tail -n 1 | sed 's/\/$//') | |
echo "Latest Tomcat Version: ${LATEST_VERSION}" | |
TOMCAT_VERSION=$(echo "${LATEST_VERSION}" | cut -c 2-) | |
# Update the shell script with the fetched values | |
sed -i "5 c MAJOR_VERSION=${MAJOR_VERSION}" tomcat.sh | |
sed -i "6 c TOMCAT_VERSION=${TOMCAT_VERSION}" tomcat.sh | |
- name: Commit updated Tomcat versions | |
run: | | |
git config --local user.name "GitHub Actions" | |
git config --local user.email "actions@github.com" | |
git add tomcat.sh | |
if ! git diff --cached --quiet; then | |
echo "Tomcat version differs, updating tomcat.sh..." | |
git commit -m "Update tomcat.sh file" | |
git push | |
else | |
echo "No changes detected, skipping commit." | |
fi |