-
-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (87 loc) · 3.57 KB
/
update-calendar.yml
File metadata and controls
102 lines (87 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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'
})