-
-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (70 loc) · 2.58 KB
/
update-calendar.yml
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
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 }}