summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Cao <[email protected]>2023-03-17 20:44:47 +0800
committerRyan Cao <[email protected]>2023-03-17 20:44:47 +0800
commit03c5675b909d07561777d2a1e88a856cec5f6ff6 (patch)
tree939543e38c0f6369dc731e191d06affeee864075
parent991db15eeeea733dcf69e0b18c1fc06e4838e929 (diff)
refactor: retrieve Git revision from Lume
-rw-r--r--.github/workflows/deploy.yaml10
-rw-r--r--_config.ts25
-rw-r--r--src/_includes/layouts/base.njk2
-rw-r--r--src/_includes/layouts/index.njk28
4 files changed, 28 insertions, 37 deletions
diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml
index 691cf6c..382cdbe 100644
--- a/.github/workflows/deploy.yaml
+++ b/.github/workflows/deploy.yaml
@@ -21,11 +21,9 @@ jobs:
uses: denoland/setup-deno@v1
with:
deno-version: v1.31.3
-
+
- name: build site
- run: |
- sed -i "s/commit:/commit: $GITHUB_SHA/" src/_includes/layouts/base.njk
- deno task build
+ run: deno task build
- name: setup pages
uses: actions/configure-pages@v3
@@ -34,7 +32,7 @@ jobs:
uses: actions/upload-pages-artifact@v1
with:
path: '_site'
-
+
- name: deploy
id: deployment
- uses: actions/deploy-pages@v1 \ No newline at end of file
+ uses: actions/deploy-pages@v1
diff --git a/_config.ts b/_config.ts
index d457326..1a2f473 100644
--- a/_config.ts
+++ b/_config.ts
@@ -8,8 +8,8 @@ import sass from "lume/plugins/sass.ts";
import sitemap from "lume/plugins/sitemap.ts";
const site = lume({
- src: "./src",
- location: new URL("https://getchoo.github.io"),
+ src: "./src",
+ location: new URL("https://getchoo.github.io"),
});
site.use(attributes());
@@ -19,7 +19,28 @@ site.use(date());
site.use(remark());
site.use(sass());
site.use(sitemap());
+
+const getGitRevision = async () => {
+ const p = Deno.run({
+ cmd: ["git", "rev-parse", "HEAD"],
+ stdout: "piped",
+ });
+ const [status, output] = await Promise.all([p.status(), p.output()]);
+
+ if (status.success) {
+ return new TextDecoder().decode(output).trim();
+ }
+
+ return null;
+};
+
+site.data(
+ "gitRevision",
+ await getGitRevision(),
+);
+
site.ignore("README.md", "LICENSE", ".gitignore", ".gitattributes");
+
site.copy("imgs");
site.copy("files");
site.copy("js");
diff --git a/src/_includes/layouts/base.njk b/src/_includes/layouts/base.njk
index 8688c95..b0fb268 100644
--- a/src/_includes/layouts/base.njk
+++ b/src/_includes/layouts/base.njk
@@ -14,7 +14,7 @@
{% block footer %}
<footer>
<a href="https://github.com/getchoo/getchoo.github.io">source</a>
- commit:
+ commit: {{ gitRevision }}
</footer>
{% endblock %}
</body>
diff --git a/src/_includes/layouts/index.njk b/src/_includes/layouts/index.njk
deleted file mode 100644
index 858569a..0000000
--- a/src/_includes/layouts/index.njk
+++ /dev/null
@@ -1,28 +0,0 @@
-{% extends "_includes/layouts/base.njk" %}
-{% block body %}
- {{ super () }}
- <div class="gifs">
- <script type="module" src="/js/chrisApp.js"></script>
- <img src="/imgs/gifs/legalize.gif" alt="legalize now!"/>
- <img src="/imgs/gifs/acab.gif" alt="acab"/>
- <img src="/imgs/gifs/poweredbyfedora.gif" alt="powered by fedora"/>
- <img src="/imgs/gifs/capitalism.gif" alt="let's crush capitalism!"/>
- <br/> <img src="/imgs/gifs/anybrowser.gif" alt="best viewed with any browser"/>
- <img src="/imgs/gifs/weezer.gif" alt="weezer fan"/>
- <img src="/imgs/gifs/steam.gif" alt="play with steam"/>
- <img src="/imgs/gifs/vi.gif" alt="made with vi"/>
- <img src="/imgs/gifs/pride.gif" alt="pride"/>
- <img src="/imgs/gifs/imagine.gif" alt="imagination"/>
- <br/> <img src="/imgs/gifs/moz.gif" alt="mozilla is cool"/>
- <img src="/imgs/gifs/free.gif" alt="completely free software"/>
- <img src="/imgs/gifs/gimp.gif" alt="graphics by gimp"/>
- <img src="/imgs/gifs/explorer.gif" alt="marijuana mind explorer"/>
- <img src="/imgs/gifs/jsfree.gif" alt="javascript free"/>
- <img src="/imgs/gifs/web3.gif" alt="keep the web free! say no to web3!"/>
- <img src="/imgs/gifs/tired.gif" alt="tired"/>
- <img src="/imgs/gifs/arnold.gif" alt="hey arnold!"/>
- <img src="/imgs/gifs/bob.gif" alt="powered by bob"/>
- <img src="/imgs/gifs/counterstrike.gif" alt="counter-strike player"/>
- <img src="/imgs/gifs/chris.gif" alt="chris troll" id="chris_gif"/>
- </div>
-{% endblock %} \ No newline at end of file