diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..9084c62 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,43 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20.x" + cache: "npm" + - name: Install npm dependencies + run: npm install + - name: Build + run: npm run build + - name: Fix permissions + run: | + chmod -c -R +rX "build/" | while read line; do + echo "::warning title=Invalid file permissions automatically fixed::$line" + done + - name: Upload GitHub Pages artifact + uses: actions/upload-pages-artifact@v2 + with: + path: build/ + deploy: + needs: build + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c9b501 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# npm +/node_modules + +# Suri +/build diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9e41033 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) 2023 Justin Stayton + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..736fb0b --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Suri × Deploy to GitHub Pages + +You're viewing a template repository tailored for deploying Suri to +[GitHub Pages](https://pages.github.com/). + +What's Suri? Suri is your own link shortener that's easily deployed as a static +site. No server-side hosting, serverless cloud functions, or database necessary. +Head over to the main [`jstayton/suri`](https://github.com/jstayton/suri) +repository to learn more, including additional deployment methods. + +## Install + +_TBD_ + +## Manage Links + +Links are managed through [`./src/links.json`](./src/links.json), which is +seeded with a few examples to start: + +```json +{ + "/": "https://github.com/jstayton/suri", + "1": "https://fee.org/articles/the-use-of-knowledge-in-society/", + "tw": "https://twitter.com" +} +``` + +It couldn't be simpler: the key is the "shortlink" path that gets redirected, +and the value is the target URL. Keys can be as short or as long as you want, +using whatever mixture of characters you want. `/` is a special entry for +redirecting the root path. + +Go ahead and make an edit, then commit and push to your repository. GitHub Pages +should automatically build and deploy your change. That's it! + +## Config + +Config options are set in [`suri.config.json`](suri.config.json). There is only +one at this point: + +| Option | Description | Type | Default | +| ------ | ------------------------------------------------------------------ | ------- | ------- | +| `js` | Whether to redirect with JavaScript instead of a `` refresh. | Boolean | `false` | diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..4a4dbf5 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,31 @@ +{ + "name": "@suri/deploy-github", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@suri/deploy-github", + "version": "1.0.0", + "license": "MIT", + "devDependencies": { + "suri": "github:jstayton/suri#v1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/suri": { + "version": "1.0.0", + "resolved": "git+ssh://git@github.com/jstayton/suri.git#eeb12749b3804d4cda135c9b46e26d4eb8e1d295", + "dev": true, + "license": "MIT", + "bin": { + "suri": "bin/suri.js" + }, + "engines": { + "node": ">=18" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..a99031c --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "@suri/deploy-github", + "version": "1.0.0", + "private": true, + "type": "module", + "description": "A template repository tailored for deploying Suri to GitHub Pages", + "homepage": "https://github.com/staticsuri/suri-deploy-github#readme", + "bugs": "https://github.com/staticsuri/suri-deploy-github/issues", + "license": "MIT", + "repository": "staticsuri/suri-deploy-github", + "scripts": { + "build": "suri" + }, + "devDependencies": { + "suri": "github:jstayton/suri#v1" + }, + "engines": { + "node": ">=18" + } +} diff --git a/src/links.json b/src/links.json new file mode 100644 index 0000000..902d279 --- /dev/null +++ b/src/links.json @@ -0,0 +1,5 @@ +{ + "/": "https://github.com/jstayton/suri", + "1": "https://fee.org/articles/the-use-of-knowledge-in-society/", + "tw": "https://twitter.com" +} diff --git a/suri.config.json b/suri.config.json new file mode 100644 index 0000000..d8351c5 --- /dev/null +++ b/suri.config.json @@ -0,0 +1,3 @@ +{ + "js": false +}