Skip to content

Check Moodle Version and Tag #10

Check Moodle Version and Tag

Check Moodle Version and Tag #10

name: Check Moodle Version and Tag
on:
schedule:
- cron: '0 0 * * *' # Run this task daily
jobs:
check-version-and-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Moodle Latest Version
id: check_moodle
run: |
LATEST_MOODLE_VERSION=$(curl -s https://api.github.com/repos/moodle/moodle/tags | jq -r '.[0].name')
echo "LATEST_MOODLE_VERSION=$LATEST_MOODLE_VERSION" >> $GITHUB_ENV
- name: Create Tag if New
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CURRENT_VERSION=$(git tag --sort=-v:refname | head -n 1)
if [ "$CURRENT_VERSION" != "$LATEST_MOODLE_VERSION" ]; then
echo "Latest version is already tagged"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag $LATEST_MOODLE_VERSION
git push origin $LATEST_MOODLE_VERSION
fi