Efficiently deploy a website to Neocities using Github actions. Uses content aware diffing to only update files that changed.
name: Deploy to neocities
# only run on changes to main. Use main or master depending on whatever your default branch is called.
on:
push:
branches:
- main
concurrency: # prevent concurrent deploys doing strange things
group: deploy-to-neocities
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Set up any tools and build steps here
# This example uses a Node.js toolchain to build a site
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Install deps and build
run: |
npm i
npm run build
# When the dist_dir is ready, deploy it to neocities
- name: Deploy to neocities
uses: bcomnes/deploy-to-neocities@v2
with:
api_token: ${{ secrets.NEOCITIES_API_TOKEN }}
cleanup: false
dist_dir: public
Create a workflow .yml
file in your repository's .github/workflows
directory. An example workflow is available above. For more information, reference the GitHub Help Documentation for Creating a workflow file.
You'll need the API token for your site. Go to:
https://neocities.org/settings/{{your-sitename}}#api_key
Get your site's API token. In your GitHub repository, set a secret called NEOCITIES_API_TOKEN
. Set the api_token
input on your deploy-to-neocities
action to ${{ secrets.NEOCITIES_API_TOKEN }}
as in the example above.
During your workflow, generate the files you want to deploy to Neocities into a directory. Set this as the dist_dir
directory in your workflow (the default is public
). You can use any tools to generate your site that can be installed or brought into the Github actions environment.
Once the build is complete, deploy-to-neocities
will efficiently upload all new and all changed files to Neocities. Any files on Neocities that don't exist in the dist_dir
are considered 'orphaned' files. To destructively remove these 'orphaned' files, set the cleanup
input to true
.
You most likely only want to run this on the master
branch so that only changes committed to master
result in website updates. Running a test build that does not deploy on all branches and PRs can help catch changes that will break the build.
api_token
(REQUIRED): The API token for your Neocities website to deploy to.dist_dir
: The directory to deploy to Neocities. Default: public
. Don't deploy your root repo directory (e.g. ./
). It contains .git
, .github
and other files that won't deploy properly to neocities. Keep it clean by keeping or building your site into a subdir and deploy that.cleanup
: Boolean string (true
or false
). If true
, deploy-to-neocities
will destructively delete files found on Neocities not found in your dist_dir
. Default: false
.protected_files
: An optional glob string used to mark files as protected. Protected files are never cleaned up. Test this option out with cleanup
set to false before relying on it. Protected files are printed when cleanup
is set to true or false. Glob strings are processed by minimatch against remote neocities file paths. Protected files can still be updated.None.
Neocities offers a bunch of nice properties:
A
and AAAA
records are all you need. Bare names and all!See changelog.md