Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: github action for deploy #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build and deploy GH Pages

## ref: https://github.com/marketplace/actions/setup-clojure
## ref: https://github.com/actions/setup-node

on:
push:
branches:
- deploy

jobs:
build:
name: Publish site
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
- name: Install clojure tools
uses: DeLaGuardo/[email protected]
with:
cli: 1.11.1.1413
- name: Cache clojure dependencies
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.gitlibs
~/.deps.clj
# List all files containing dependencies:
key: cljdeps-${{ hashFiles('deps.edn') }}
# key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }}
# key: cljdeps-${{ hashFiles('project.clj') }}
# key: cljdeps-${{ hashFiles('build.boot') }}
restore-keys: cljdeps-
- name: setup_npm
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- name: build_and_deploy
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
GITHUB_HOSTNAME="github.com"
TARGET_REPOSITORY=${GITHUB_REPOSITORY}
remote_repo="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@${GITHUB_HOSTNAME}/${TARGET_REPOSITORY}.git"
remote_branch="gh-pages"

npm install
npm run build

echo "Pushing artifacts to ${TARGET_REPOSITORY}:$remote_branch"

cd resources/public

git init
git config user.name "GitHub Actions"
git config user.email "[email protected].${GITHUB_HOSTNAME}"
git add .

git commit -m "Deploy ${TARGET_REPOSITORY} to ${TARGET_REPOSITORY}:$remote_branch"
git push --force "${remote_repo}" master:"${remote_branch}"

echo "Deploy complete"
Empty file added resources/public/.nojekyll
Empty file.
10 changes: 5 additions & 5 deletions resources/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<meta name="title" content="Try Clojure">
<meta name="description" content="Clojure tutorial in a browser REPL.">

<link rel="shortcut icon" type="image/x-icon" href="/images/clojure-logo-icon-32.png">
<link rel="apple-touch-icon" href="/images/clojure-logo-icon-256.png">
<link rel="shortcut icon" type="image/x-icon" href="./images/clojure-logo-icon-32.png">
<link rel="apple-touch-icon" href="./images/clojure-logo-icon-256.png">

<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
Expand All @@ -27,8 +27,8 @@
<meta property="twitter:image" content="">

<!-- Styles -->
<link rel="stylesheet" href="/css/styles.css" type="text/css">
<link rel="stylesheet" href="/fonts/inter.css" type="text/css">
<link rel="stylesheet" href="./css/styles.css" type="text/css">
<link rel="stylesheet" href="./fonts/inter.css" type="text/css">
</head>
<body>

Expand All @@ -37,7 +37,7 @@
</div>

<!-- JS -->
<script type="text/javascript" src="/js/app.js"></script>
<script type="text/javascript" src="./js/app.js"></script>
<!-- Analytics -->
<script data-goatcounter="https://no-code.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
</body>
Expand Down