-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (73 loc) · 3.37 KB
/
convert_ics.yaml
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: Convert ICS & Create PRs
on:
push:
branches:
- main
paths:
- "ics/**" # Trigger workflow when changes are pushed to 'ics' directory
jobs:
convert-and-create-pr:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Check and Convert
run: |
for file in ics/*.ics; do
year=$(basename "$file" .ics)
# CSV Conversion
if [ ! -f "csv/$year.csv" ]; then
git config --global user.email "77499497+Dilshan-H@users.noreply.github.com"
git config --global user.name "dilshan-h"
csv_branch_name="csv-files-$year"
git pull origin main
git checkout -b "$csv_branch_name"
python converters/icalendar_to_csv.py "$file"
git add "csv/$year.csv"
git commit -m "Convert $year.ics to $year.csv [skip ci]"
git push origin "$csv_branch_name"
gh pr create --title "Convert $year.ics to $year.csv" --body "[Automated PR] This PR contains the changes after converting $year.ics to $year.csv." --base main --head "$csv_branch_name"
else
echo "CSV file for $year.ics already exists. Skipping CSV conversion."
fi
# XML Conversion
if [ ! -f "xml/$year.xml" ]; then
git config --global user.email "77499497+Dilshan-H@users.noreply.github.com"
git config --global user.name "dilshan-h"
xml_branch_name="xml-files-$year"
git checkout -b "$xml_branch_name"
python converters/icalendar_to_xml.py "$file"
git add "xml/$year.xml"
git commit -m "Convert $year.ics to $year.xml [skip ci]"
git push origin "$xml_branch_name"
gh pr create --title "Convert $year.ics to $year.xml" --body "[Automated PR] This PR contains the changes after converting $year.ics to $year.xml." --base main --head "$xml_branch_name"
else
echo "XML file for $year.ics already exists. Skipping XML conversion."
fi
# JSON Conversion
if [ ! -f "json/$year.json" ]; then
git config --global user.email "77499497+Dilshan-H@users.noreply.github.com"
git config --global user.name "dilshan-h"
json_branch_name="json-files-$year"
git checkout -b "$json_branch_name"
python converters/icalendar_to_json.py "$file"
git add "json/$year.json"
git commit -m "Convert $year.ics to $year.json [skip ci]"
git push origin "$json_branch_name"
gh pr create --title "Convert $year.ics to $year.json" --body "[Automated PR] This PR contains the changes after converting $year.ics to $year.json." --base main --head "$json_branch_name"
else
echo "JSON file for $year.ics already exists. Skipping JSON conversion."
fi
done