How I Deploy to Neocities with GitHub Actions
- A Neocities account (duh!)
- A GitHub account
- A website you want to deploy (HTML, CSS, JavaScript, etc.)
- A basic understanding of Git (don't worry, it's not that scary)
First things first, throw up all ur website files on a GitHub repo. It can be public or private, don't matter. If you're not familiar with Git or GitHub, you should be. Here are some helpful resources:
Neocities has a bitchin API. To use it, u need an API key. Here's how to get it:
- Go to your Neocities site settings:
https://neocities.org/settings/[your-sitename]#api_key
- Generate an API key if you haven't already. Keep that shit secret!
This is where the magic happens. We'll create a special file that tells GitHub Actions what to do.
- In your GitHub repository, create a file named
.github/workflows/deploy.yml
(or.github/deploy.yml
). - Paste the following code into
deploy.yml
, making the necessary adjustments:
name: Deploy to Neocities
on:
push:
branches:
- main # Replace 'main' with your default branch name
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy to Neocities
uses: bcomnes/deploy-to-neocities@v1
with:
api_token: ${{ secrets.NEOCITIES_API_TOKEN }}
dist_dir: . # Deploy the entire repository contents
cleanup: true # (Optional) Remove orphaned files
i took this code from someone a while ago. i can't remember where i saw it, so sorry! if anyone knows please lmk!
We need to store your Neocities API key securely in your GitHub repository.
- In your GitHub repository, go to "Settings" -> "Secrets and variables" -> "Actions".
- Create a new secret named
NEOCITIES_API_TOKEN
and paste your Neocities API key as its value.
Commit the changes to your repository (including the deploy.yml
file) and push them to GitHub. Now, whenever you push changes to your repository, GitHub Actions will automatically deploy your website to Neocities!
If you encounter any issues, check the workflow logs in the "Actions" tab of your repository for error messages.
That's it! Enjoy the convenience of automatic deployments and happy website building!