Skip to content

Commit c91b9c2

Browse files
committed
Initial commit
0 parents  commit c91b9c2

File tree

9 files changed

+219
-0
lines changed

9 files changed

+219
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.github/workflows/deploy.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: deploy
11+
cancel-in-progress: false
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20.x
22+
cache: npm
23+
- name: Install npm dependencies
24+
run: npm install
25+
- name: Build with Suri
26+
run: npm run build
27+
- name: Upload GitHub Pages artifact
28+
uses: actions/upload-pages-artifact@v3
29+
with:
30+
path: build/
31+
deploy:
32+
needs: build
33+
permissions:
34+
pages: write
35+
id-token: write
36+
environment:
37+
name: github-pages
38+
url: ${{ steps.deployment.outputs.page_url }}
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Deploy to GitHub Pages
42+
id: deployment
43+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# npm
2+
/node_modules
3+
4+
# Suri
5+
/build

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Justin Stayton
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<h1 align="center" width="100%">
2+
<img src="https://raw.githubusercontent.com/surishortlink/suri/HEAD/logo.png" width="200" alt="Suri" />
3+
</h1>
4+
5+
<h3 align="center" width="100%">
6+
<i>Your own short links as an easily deployed static site on GitHub Pages</i>
7+
</h3>
8+
9+
You're viewing a template repository tailored for deploying Suri to
10+
[GitHub Pages](https://pages.github.com/) with
11+
[GitHub Actions](https://docs.github.com/en/actions). Head over to
12+
[the main repository](https://github.com/surishortlink/suri) to learn more about
13+
Suri, including additional deployment options.
14+
15+
## Setup: Step By Step
16+
17+
1. Hit the "Use this template" button above and then "Create a new repository".
18+
Fill in the required details to create a new repository based on this one.
19+
2. Go to the "Settings" of your new repository and head to the "Pages" section.
20+
Under "Build and deployment", change the "Source" to "GitHub Actions".
21+
3. Go to the "Actions" of your new repository. There should be a workflow run
22+
that likely failed because the previous step wasn't yet completed. Go ahead
23+
and view the workflow run and hit the "Re-run jobs" button.
24+
25+
### Auto-Deploy
26+
27+
Any commits to the `main` branch of your new repository will trigger a new build
28+
and deploy. You can change this by editing
29+
[`.github/workflows/deploy.yml`](.github/workflows/deploy.yml), which is the
30+
GitHub Actions workflow for building the site and deploying to GitHub Pages.
31+
32+
### Custom Domain
33+
34+
To use a custom domain, follow GitHub's guide:
35+
[Managing a custom domain for your GitHub Pages site](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site).
36+
37+
## How It Works
38+
39+
### Manage Links
40+
41+
At the heart of Suri is the [`links.json`](src/links.json) file, located in the
42+
`src` directory, where you manage your links. All of the template repositories
43+
include this file seeded with a few examples:
44+
45+
```json
46+
{
47+
"/": "https://www.youtube.com/watch?v=CsHiG-43Fzg",
48+
"1": "https://fee.org/articles/the-use-of-knowledge-in-society/",
49+
"gh": "https://github.com/surishortlink/suri"
50+
}
51+
```
52+
53+
It couldn't be simpler: the key is the "short link" path that gets redirected,
54+
and the value is the target URL. Keys can be as short or as long as you want,
55+
using whatever mixture of characters you want. `/` is a special entry for
56+
redirecting the root path.
57+
58+
### Build Static Site
59+
60+
Suri ships with a `suri` executable file that generates the static site from the
61+
`links.json` file. The static site is output to a directory named `build`.
62+
63+
All of the template repositories are configured with a `build` script that
64+
invokes this executable, making the command you run simple:
65+
66+
```bash
67+
npm run build
68+
```
69+
70+
When you make a change to the `links.json` file, simply re-run this command to
71+
re-generate the static site, which can then be re-deployed. This template
72+
repository is configured to do this automatically.
73+
74+
### Config
75+
76+
Configuration is handled through the [`suri.config.json`](suri.config.json) file
77+
in the root directory. There is only one option at this point:
78+
79+
| Option | Description | Type | Default |
80+
| ------ | ------------------------------------------------------------------ | ------- | ------- |
81+
| `js` | Whether to redirect with JavaScript instead of a `<meta>` refresh. | Boolean | `false` |
82+
83+
### Public Directory
84+
85+
Finally, any files in the `public` directory will be copied over to the `build`
86+
directory without modification when the static site is built. This can be useful
87+
for files like `favicon.ico` or `robots.txt` (that said, Suri provides sensible
88+
defaults for both).

package-lock.json

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

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "@surishortlink/deploy-github",
3+
"version": "1.0.0",
4+
"private": true,
5+
"type": "module",
6+
"description": "A template repository tailored for deploying Suri to GitHub Pages",
7+
"homepage": "https://github.com/surishortlink/suri-deploy-github#readme",
8+
"bugs": "https://github.com/surishortlink/suri-deploy-github/issues",
9+
"license": "MIT",
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/surishortlink/suri-deploy-github.git"
13+
},
14+
"scripts": {
15+
"build": "suri"
16+
},
17+
"devDependencies": {
18+
"@surishortlink/suri": "^1"
19+
},
20+
"engines": {
21+
"node": ">=18"
22+
}
23+
}

src/links.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"/": "https://www.youtube.com/watch?v=CsHiG-43Fzg",
3+
"1": "https://fee.org/articles/the-use-of-knowledge-in-society/",
4+
"gh": "https://github.com/surishortlink/suri"
5+
}

suri.config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"js": false
3+
}

0 commit comments

Comments
 (0)