Check for LÖVE version update & update if theres a new version #2
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: Check for LÖVE version update & update if theres a new version | |
on: | |
schedule: | |
- cron: '0 0 1 * *' # Runs the workflow on the 1st day of every month at midnight UTC | |
workflow_dispatch: # Manually triggered workflow | |
jobs: | |
check_version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y curl grep | |
- name: Extract LÖVE version from love2d.org | |
id: extract_version | |
run: | | |
VERSION=$(curl -s https://love2d.org/ | grep -oP '<h2>Download LÖVE \K[0-9]+\.[0-9]+' | tr -d '\n') | |
echo $VERSION | |
echo $VERSION > remote-version.txt | |
echo "::set-output name=version::$VERSION" | |
- name: Compare with latest version | |
id: compare_versions | |
run: | | |
LATEST_VERSION=$(cat latest-version.txt) | |
$(cat remote-version.txt) | |
$(cat latest-version.txt) | |
echo "remote ${{ steps.extract_version.outputs.version }}" | |
if [ "$LATEST_VERSION" != "${{ steps.extract_version.outputs.version }}" ]; then | |
echo "LÖVE version updated." | |
echo "${{ steps.extract_version.outputs.version }}" > latest-version.txt | |
else | |
echo "LÖVE version unchanged." | |
exit 1 | |
fi | |
- name: Commit and push changes | |
run: | | |
git config --local user.email "actions@github.com" | |
git config --local user.name "GitHub Actions" | |
git add remote-version.txt | |
git commit -m "Automatic Update of remote-version.txt" | |
git push | |
mirror_website: | |
needs: check_version | |
if: failure() # Only runs if the version check fails | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install HTTrack | |
run: sudo apt-get install httrack -y | |
- name: Mirror love2d.org | |
run: httrack https://love2d.org/ -O ./love2d.org | |
- name: Update latest version | |
run: echo ::set-output name=version::$(cat latest-version.txt) | |
- name: Commit and push changes | |
run: | | |
git config --local user.email "actions@github.com" | |
git config --local user.name "GitHub Actions" | |
git add README.md | |
git commit -m "Automatic love2d.org/" | |
git push | |