Skip to content

Update calendar release #7668

Update calendar release

Update calendar release #7668

name: Update calendar release
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
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"
jobs:
update-calendar:
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@master
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: curl
- name: "Generate calendar files"
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/sportclimbing/ifsc-calendar:latest
options: -v ${{ github.workspace }}:/calendar
run: |
ifsc-calendar \
--season 2024 \
--output "/calendar/${{ env.CALENDAR_FILE_ICS }}" \
--format "ics,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: "Generate tag name"
id: date
if: steps.check_diff.outputs.has_changes == 'true'
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@v1
if: steps.check_diff.outputs.has_changes == 'true'
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'
uses: Actions-R-Us/actions-tagger@latest
with:
publish_latest_tag: true
- name: "Notify update"
if: steps.check_diff.outputs.has_changes == 'true'
run: php bin/notify-update
env:
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}