Check Editor Releases #3
This file contains hidden or 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 Editor Releases | |
| on: | |
| schedule: | |
| - cron: "0 8 * * *" # Daily at 8:00 UTC | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| check_and_build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get latest exelearning release | |
| id: check | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Fetch latest release from exelearning/exelearning | |
| LATEST=$(gh api repos/exelearning/exelearning/releases/latest --jq '.tag_name' 2>/dev/null || echo "") | |
| if [ -z "$LATEST" ]; then | |
| echo "No release found" | |
| echo "found=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "Latest editor release: $LATEST" | |
| echo "tag=$LATEST" >> $GITHUB_OUTPUT | |
| # Check if we already built this version | |
| MARKER_FILE=".editor-version" | |
| CURRENT="" | |
| if [ -f "$MARKER_FILE" ]; then | |
| CURRENT=$(cat "$MARKER_FILE") | |
| fi | |
| echo "Current built version: $CURRENT" | |
| if [ "$LATEST" = "$CURRENT" ]; then | |
| echo "Already up to date" | |
| echo "found=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "New version available" | |
| echo "found=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Bun | |
| if: steps.check.outputs.found == 'true' | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Build static editor | |
| if: steps.check.outputs.found == 'true' | |
| env: | |
| EXELEARNING_EDITOR_REPO_URL: https://github.com/exelearning/exelearning.git | |
| EXELEARNING_EDITOR_REF: ${{ steps.check.outputs.tag }} | |
| EXELEARNING_EDITOR_REF_TYPE: tag | |
| run: make build-editor | |
| - name: Compute version | |
| if: steps.check.outputs.found == 'true' | |
| id: version | |
| run: | | |
| TAG="${{ steps.check.outputs.tag }}" | |
| VERSION="${TAG#v}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| - name: Create package | |
| if: steps.check.outputs.found == 'true' | |
| run: make package RELEASE=${{ steps.version.outputs.version }} | |
| - name: Update editor version marker | |
| if: steps.check.outputs.found == 'true' | |
| run: | | |
| echo "${{ steps.check.outputs.tag }}" > .editor-version | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add .editor-version | |
| git commit -m "Update editor version to ${{ steps.check.outputs.tag }}" | |
| git push | |
| - name: Create GitHub Release | |
| if: steps.check.outputs.found == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: "${{ steps.version.outputs.tag }}" | |
| body: | | |
| Automated build with eXeLearning editor ${{ steps.version.outputs.tag }}. | |
| files: mod_exeweb-${{ steps.version.outputs.version }}.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |