Update calendar release #8694
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: "Update calendar release" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| force_release: | |
| description: 'Force release even if no calendar changes are detected' | |
| required: false | |
| type: boolean | |
| default: false | |
| schedule: | |
| - cron: '0 5 * * *' | |
| permissions: | |
| contents: write | |
| env: | |
| CALENDAR_FILE_ICS: "IFSC-World-Cups-and-World-Championships.ics" | |
| CALENDAR_FILE_JSON: "IFSC-World-Cups-and-World-Championships.json" | |
| LATEST_CALENDAR_URL: "https://github.com/sportclimbing/ifsc-calendar/releases/latest/download/IFSC-World-Cups-and-World-Championships.json" | |
| LATEST_SCHEDULE_URL: "https://github.com/sportclimbing/event-schedule/releases/latest/download/events-with-schedules.json" | |
| YEAR: 2026 | |
| jobs: | |
| update-calendar: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "Checkout code" | |
| uses: actions/checkout@v6 | |
| - name: "Setup PHP" | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.5' | |
| extensions: curl | |
| - name: "Download latest schedule" | |
| run: curl -fsSL "${{ env.LATEST_SCHEDULE_URL }}" --output events-with-schedules.json | |
| - name: "Generate calendar files" | |
| uses: maus007/docker-run-action-fork@v1 | |
| with: | |
| image: ghcr.io/sportclimbing/ifsc-calendar:latest | |
| options: -v ${{ github.workspace }}:/calendar | |
| run: ifsc-calendar --season ${{ env.YEAR }} --output "/calendar/${{ env.CALENDAR_FILE_ICS }}" --format "ics,json" --with-schedule "events-with-schedules.json" | |
| - name: "Validate calendar" | |
| run: php bin/validate-calendar "${{ env.CALENDAR_FILE_JSON }}" | |
| - name: "Check diff" | |
| id: check_diff | |
| run: | | |
| curl -sSL "${{ env.LATEST_CALENDAR_URL }}" --output old-calendar.json | |
| php bin/calendar-diff old-calendar.json "${{ env.CALENDAR_FILE_JSON }}" > diff.md || true | |
| if [ $(wc -w < diff.md) -gt 0 ]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: "Add force release note" | |
| if: inputs.force_release | |
| run: | | |
| printf '> [!NOTE]\n> This release was manually force-released.\n\n' | cat - diff.md > tmp.md && mv tmp.md diff.md | |
| - name: "Generate tag name" | |
| id: date | |
| if: steps.check_diff.outputs.has_changes == 'true' || inputs.force_release | |
| run: | | |
| echo "tag_name=$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT | |
| echo "name=$(date +'%Y/%m/%d, %H:%M') Release" >> $GITHUB_OUTPUT | |
| - name: "Add release" | |
| uses: softprops/action-gh-release@v2 | |
| if: steps.check_diff.outputs.has_changes == 'true' || inputs.force_release | |
| with: | |
| files: | | |
| ${{ env.CALENDAR_FILE_ICS }} | |
| ${{ env.CALENDAR_FILE_JSON }} | |
| tag_name: ${{ steps.date.outputs.tag_name }} | |
| name: ${{ steps.date.outputs.name }} | |
| body_path: diff.md | |
| - name: "Run latest-tag" | |
| if: steps.check_diff.outputs.has_changes == 'true' || inputs.force_release | |
| uses: Actions-R-Us/actions-tagger@latest | |
| with: | |
| publish_latest_tag: true | |
| - name: "Deploy Calendar Web" | |
| if: steps.check_diff.outputs.has_changes == 'true' || inputs.force_release | |
| uses: actions/github-script@v8 | |
| with: | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: '${{ github.repository_owner }}', | |
| repo: 'web', | |
| workflow_id: 'static-deploy.yml', | |
| ref: 'main' | |
| }) |