|
1 | | -# yaml to ics calendar |
| 1 | +# YAML to ics calendar |
2 | 2 |
|
3 | | -This repository turns yaml files into icl calendars (importable into |
| 3 | +This repository turns yaml files into .ics calendars (importable into |
4 | 4 | different programs) using |
5 | 5 | [yaml2ics](https://github.com/scientific-python/yaml2ics) and GitHub |
6 | | -actions. |
| 6 | +actions. Or, you can use git-calendar directly. |
7 | 7 |
|
8 | 8 | This repository provides a working template for the action to build + |
9 | | -publish to Github Pages, and some minimal HTML index pages. All of |
10 | | -the important logic is in |
| 9 | +publish to Github Pages, including files into other files, and some |
| 10 | +minimal HTML index pages. All of the important logic is in |
11 | 11 | [yaml2ics](https://github.com/scientific-python/yaml2ics), so if you |
12 | 12 | want to roll your own site and build system (which isn't hard) for the |
13 | 13 | .ics files, consider using yaml2ics directly. |
14 | 14 |
|
15 | | -This is sort of alpha: it works and is used, but code editing or |
16 | | -asking for clarifications is probably needed. Documentation should be |
17 | | -improved. |
18 | 15 |
|
19 | 16 |
|
20 | | - |
21 | | -## Example |
| 17 | +## Example deployments |
22 | 18 |
|
23 | 19 | The CodeRefinery calendar |
24 | 20 | * [Built calendar site](https://coderefinery.github.io/calendar/) |
25 | | - (main landing page for most projects) |
| 21 | + (the auto-generated landing page) |
26 | 22 | * [Source repository](https://github.com/coderefinery/calendar) |
27 | 23 | * Optional: [Calendars inserted into |
28 | 24 | website](https://coderefinery.org/calendars/) ([source](https://github.com/coderefinery/coderefinery.org/blob/main/content/calendars.md)) |
29 | 25 |
|
30 | 26 |
|
31 | 27 |
|
32 | | -## Usage |
| 28 | +## General principles |
33 | 29 |
|
34 | | -To use, look at |
35 | | -[git-calendar-template](https://github.com/coderefinery/git-calendar-template) |
36 | | -for a sample repository that uses this. Generate your own repository |
37 | | -from that template and go from there. |
| 30 | +One defines events in YAML, and they get built to `.ics` files which |
| 31 | +can be served as a static site. These can then be imported to various |
| 32 | +calendar clients. |
38 | 33 |
|
39 | | -This repository can also be installed as a Python pip package. |
| 34 | +There's a command line program, `git-calendar`, which takes YAML files |
| 35 | +as input (one of which can be named `_config.yaml`). The last |
| 36 | +argument is the output directory to which to write. |
40 | 37 |
|
41 | | -Usage in short: |
| 38 | +A typical repository layout: |
42 | 39 |
|
43 | 40 | - `calendars/*.yaml` contains the input calendars. |
44 | | -- `./build.sh` builds the outputs. Edit this script as |
45 | | - needed, or copy the command to your own build script. |
46 | | - - `out/index.html` gets build and serves as a landing page |
47 | | - - Calendars get build to `out/*.ics` |
48 | | - - The Github Actions workflow file deploys `out/` to the `gh-pages` |
49 | | - branch. |
50 | | - |
51 | | -- **First time deployment note:** you have to go to settings and |
52 | | - toggle pages off and on again the first time to enable Github Pages, |
53 | | - after that Github Actions will automatically deploy. |
| 41 | +- `output/` is the web root for web deployment |
| 42 | +- `output/*.ics` is the build calendars |
| 43 | +- `output/index.html` gets built and serves as a landing page with |
| 44 | + links to the .ics files |
54 | 45 |
|
55 | 46 | For now, see `calendars/example.yaml` for an example, or any of the |
56 | 47 | test calendars in yaml2ics. This documentation should be improved. |
57 | 48 |
|
58 | 49 |
|
59 | 50 |
|
| 51 | +## Usage - Github action |
| 52 | + |
| 53 | +This can be used as Github action (see EXAMPLE REPO for the full file). |
| 54 | + |
| 55 | +```yaml |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + - name: git-calendar action |
| 58 | + uses: coderefinery/git-calendar@action-test |
| 59 | + with: |
| 60 | + input_dir: calendars # the default, not required |
| 61 | + output_dir: output # the default, not required |
| 62 | + index_file: index.html # the default, set to '' to not |
| 63 | + create |
| 64 | + htmlbody_file: body.html # Only the part inside <body> for inclusion in other files |
| 65 | +``` |
| 66 | +
|
| 67 | +This action will automatically deploy to Github Pages. You can set |
| 68 | +`with: pages_deploy: false` to disable this. The action will also |
| 69 | +setup Python and install this Python library. If you already set up |
| 70 | +Python, it may be easier to code up your own action than use this. |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +## Usage - Raw Github action |
| 75 | + |
| 76 | +If you want to program the action yourself, below is the base. You |
| 77 | +probably can probably figure out how to integrate this to a Github |
| 78 | +Pages deployment and all. |
| 79 | +```yaml |
| 80 | + - name: build |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + git-calendar calendars/*.yaml output/ --index=index.html --edit-link=https://github.com/$GITHUB_REPOSITORY |
| 84 | +``` |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | +## Usage - command line |
| 89 | + |
| 90 | +This is a Python package, install as normal (yes, in a virtual environment, etc...): |
| 91 | +```console |
| 92 | +$ pip install git-calendar |
| 93 | +``` |
| 94 | + |
| 95 | +Then run: |
| 96 | + |
| 97 | +```console |
| 98 | +$ git-calendar calendars/*.yaml output/ --index=index.html --edit-link=https://github.com/$GITHUB_REPOSITORY |
| 99 | +``` |
| 100 | + |
| 101 | +There are more options, not currently documented. |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +## Usage - via raw yaml2ics |
| 106 | + |
| 107 | +Don't forget this is just a wrapper around |
| 108 | +[yaml2ics](https://github.com/scientific-python/yaml2ics) - if you |
| 109 | +only need a .ics file and not index.html, including calendars in |
| 110 | +others, etc., then maybe that is your starting point: |
| 111 | + |
| 112 | +```console |
| 113 | +$ python yaml2ics.py example/test_calendar.yaml example/another_calendar.yaml > out.ics |
| 114 | +``` |
| 115 | + |
| 116 | + |
| 117 | + |
60 | 118 | ## Status |
61 | 119 |
|
62 | | -Alpha, it works but may require code changes still to get around |
63 | | -corner cases. |
| 120 | +Beta as of 2025, it works but may require code changes still to get |
| 121 | +around corner cases. As of 2025 issues will probably be responded to. |
64 | 122 |
|
65 | 123 |
|
66 | 124 |
|
67 | | -## See Also |
| 125 | +## See also |
68 | 126 |
|
69 | 127 | * This directly uses https://github.com/scientific-python/yaml2ics as |
70 | 128 | the yaml to ical generator - if you want to create your own build |
|
0 commit comments