violet : home / etc / neocities-automatic-deployment /

How I Deploy to Neocities with GitHub Actions

What You'll Need
Step 1: GitHub Repository

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:

Step 2: Get Your Neocities API Key

Neocities has a bitchin API. To use it, u need an API key. Here's how to get it:

  1. Go to your Neocities site settings: https://neocities.org/settings/[your-sitename]#api_key
  2. Generate an API key if you haven't already. Keep that shit secret!
Step 3: Set Up the GitHub Actions Workflow

This is where the magic happens. We'll create a special file that tells GitHub Actions what to do.

  1. In your GitHub repository, create a file named .github/workflows/deploy.yml (or .github/deploy.yml).
  2. 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!

Step 4: Add Your API Key as a Secret

We need to store your Neocities API key securely in your GitHub repository.

  1. In your GitHub repository, go to "Settings" -> "Secrets and variables" -> "Actions".
  2. Create a new secret named NEOCITIES_API_TOKEN and paste your Neocities API key as its value.
Step 5: Test It Out!

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!

Troubleshooting

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!