Skip to content

Commit 0576c1a

Browse files
authored
Merge pull request #37 from ClojureCivitas/skip-if-unchanged
skip-if-unchanged feature and tutorial
2 parents 087cfd4 + 0a5ba44 commit 0576c1a

File tree

7 files changed

+164
-2
lines changed

7 files changed

+164
-2
lines changed

clay.edn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
:hide-info-line false
1818
:quarto []
1919
:flatten-targets false
20-
:keep-sync-root false}}
20+
:keep-sync-root false
21+
:skip-if-unchanged true}}
2122

deps.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
clj-thamil/clj-thamil {:mvn/version "0.2.0"}
1414
org.scicloj/clay {#_#_:mvn/version "2-beta46"
1515
:git/url "https://github.com/scicloj/clay.git"
16-
:git/sha "929fabcdba6473416bc292fce12300274b22f406"}
16+
:git/sha "bd1c6090a62ce07f5dbaa7f6787c2cbbe7c07d5e"}
1717
org.eclipse.elk/org.eclipse.elk.core {:mvn/version "0.10.0"}
1818
org.eclipse.elk/org.eclipse.elk.graph {:mvn/version "0.10.0"}
1919
org.eclipse.elk/org.eclipse.elk.graph.json {:mvn/version "0.10.0"}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
author:
3+
name: Daniel Slutsky
4+
image: https://avatars.githubusercontent.com/u/5673102?v=4
5+
url: https://scicloj.github.io/contributors/daslu/
6+
affiliation:
7+
- {name: Scicloj, url: 'https://scicloj.github.io/'}
8+
links:
9+
- {icon: github, href: 'https://github.com/daslu'}
10+
description: A demonstration of our practice with some Civitas notebooks that cannot be run in GitHub Pages.
11+
image: skip-if-unchanged.jpg
12+
type: post
13+
date: '2025-07-25'
14+
category: clay
15+
tags: [clay, workflow]
16+
format:
17+
html: {title: Some Civitas notebooks should only be run locally}
18+
19+
---
20+
<style></style><style>.printedClojure .sourceCode {
21+
background-color: transparent;
22+
border-style: none;
23+
}
24+
</style><style>.clay-limit-image-width .clay-image {max-width: 100%}
25+
.clay-side-by-side .sourceCode {margin: 0}
26+
.clay-side-by-side {margin: 1em 0}
27+
</style>
28+
<script src="skip_if_unchanged_example_files/md-default0.js" type="text/javascript"></script><script src="skip_if_unchanged_example_files/md-default1.js" type="text/javascript"></script>
29+
Usually, when we wish to create Clojure Civitas posts, we enjoy the fact
30+
that Civitas runs our notebooks in the GitHub Actions as it renders the website.
31+
32+
While this is the default behavior, sometimes, we cannot expect our notebooks
33+
to be run in GitHub Actions. For example, they may depend on a local file
34+
or service.
35+
36+
This notebook, for example, assumes that you have a local secrets file
37+
and it will not work without it!
38+
39+
40+
::: {.sourceClojure}
41+
```clojure
42+
(slurp "/home/daslu/my-secret.txt")
43+
```
44+
:::
45+
46+
47+
48+
::: {.printedClojure}
49+
```clojure
50+
"this is my secret!!!!!\n"
51+
52+
```
53+
:::
54+
55+
56+
If you are the author of such a notebook, the recommended practice is to
57+
render the notebook locally usinc Clay in Quarto `.qmd` format, and include
58+
that file in your Pull Request.
59+
60+
The `.qmd` file is all that Civitas needs to include your notebook in the
61+
website. As long as the `.qmd` file is included in the PR, and is not older than
62+
your source `.clj` file, Civitas will just rely on it and not even try
63+
to generate it in GitHub Actions.
64+
65+
To do that, you will need to make the file locally with a Quarto target.
66+
67+
Here are two ways to do that:
68+
69+
1. Use the command line.
70+
Note that here, we use the path to the notebook, relative to `src`.
71+
```sh
72+
clojure -M:clay -A:markdown scicloj/clay/skip_if_unchanged_example.clj
73+
```
74+
75+
2. .. Or do the same in Clojure code.
76+
77+
78+
::: {.sourceClojure}
79+
```clojure
80+
(comment
81+
(require '[scicloj.clay.v2.api :as clay])
82+
(clay/make! {:source-path "scicloj/clay/skip_if_unchanged_example.clj"
83+
:aliases [:markdown]}))
84+
```
85+
:::
86+
87+
88+
Now, need to `git add` the generated `qmd` file.
89+
Here is how.
90+
91+
92+
```{=html}
93+
<div style="background-color:grey;height:2px;width:100%;"></div>
94+
```
95+
96+
97+
98+
```{=html}
99+
<div><pre><small><small>source: <a href="https://github.com/ClojureCivitas/clojurecivitas.github.io/blob/main/src/scicloj/clay/skip_if_unchanged_example.clj">src/scicloj/clay/skip_if_unchanged_example.clj</a></small></small></pre></div>
100+
```

site/scicloj/clay/skip_if_unchanged_example_files/md-default0.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/scicloj/clay/skip_if_unchanged_example_files/md-default1.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
246 KB
Loading
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
^{:kindly/hide-code true
2+
:clay
3+
{:title "Some Civitas notebooks should only be run locally"
4+
:quarto {:author :daslu
5+
:description "A demonstration of our practice with some Civitas notebooks that cannot be run in GitHub Pages."
6+
:image "skip-if-unchanged.jpg"
7+
:type :post
8+
:date "2025-07-25"
9+
:category :clay
10+
:tags [:clay :workflow]}}}
11+
12+
(ns scicloj.clay.skip-if-unchanged)
13+
14+
;; Usually, when we wish to create Clojure Civitas posts, we enjoy the fact
15+
;; that Civitas runs our notebooks in the GitHub Actions as it renders the website.
16+
17+
;; While this is the default behavior, sometimes, we cannot expect our notebooks
18+
;; to be run in GitHub Actions. For example, they may depend on a local file
19+
;; or service.
20+
21+
;; This notebook, for example, assumes that you have a local secrets file
22+
;; and it will not work without it!
23+
24+
(slurp "/home/daslu/my-secret.txt")
25+
26+
;; If you are the author of such a notebook, the recommended practice is to
27+
;; render the notebook locally usinc Clay in Quarto `.qmd` format, and include
28+
;; that file in your Pull Request.
29+
30+
;; The `.qmd` file is all that Civitas needs to include your notebook in the
31+
;; website. As long as the `.qmd` file is included in the PR, and is not older than
32+
;; your source `.clj` file, Civitas will just rely on it and not even try
33+
;; to generate it in GitHub Actions.
34+
35+
;; To do that, you will need to make the file locally with a Quarto target.
36+
37+
;; Here are two ways to do that:
38+
39+
;; 1. Use the command line.
40+
;; Note that here, we use the path to the notebook, relative to `src`.
41+
;; ```sh
42+
;; clojure -M:clay -A:markdown scicloj/clay/skip_if_unchanged_example.clj
43+
;; ```
44+
45+
;; 2. .. Or do the same in Clojure code.
46+
(comment
47+
(require '[scicloj.clay.v2.api :as clay])
48+
(clay/make! {:source-path "scicloj/clay/skip_if_unchanged_example.clj"
49+
:aliases [:markdown]}))
50+
51+
52+
;; Now, need to `git add` the generated `qmd` file.
53+
;; Here is how.

0 commit comments

Comments
 (0)