docs: Document action, inputs and outputs.

This commit is contained in:
Bret Comnes 2020-02-17 21:12:06 -07:00
parent 6b86fa30b4
commit da5f527254
No known key found for this signature in database
GPG Key ID: 3705F4634DC3A1AC
4 changed files with 41 additions and 6 deletions

View File

@ -2,8 +2,43 @@
[![Actions Status](https://github.com/bcomnes/deploy-to-neocities/workflows/tests/badge.svg)](https://github.com/bcomnes/deploy-to-neocities/actions) [![Actions Status](https://github.com/bcomnes/deploy-to-neocities/workflows/tests/badge.svg)](https://github.com/bcomnes/deploy-to-neocities/actions)
<center><img src="logo.png"></center>
Efficiently deploy a website to [Neocities][nc].
### Pre-requisites
Create a workflow `.yml` file in your repositories `.github/workflows` directory. An [example workflow](#example-workflow) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).
Get your sites API token and set a [secret][sec] called `NEOCITIES_API_TOKEN`. Set the `api_token` input on your `deploy-to-neocities` action to `NEOCITIES_API_TOKEN`.
```
https://neocities.org/settings/{{sitename}}#api_key
```
During your workflow, generate the files you want to deploy to [Neocities][nc] into a `distDir` directory. You can use any tools that can be installed or brought into the Github actions environment.
This `dist_dir` should be specified as the `distDir` input. Once the build is complete, the `deploy-to-neocities` action will efficiently upload all new and all changed files to Neocities. Any files on Neocities that don't exist in the `distDir` are considdered 'orphaned' files. To destrucively 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 commited to `master` result in website updates.
### Inputs
- `api_token` (**REQUIRED**): The api token for your [Neocities][nc] website to deploy to.
- `dist_dir`: The directory to deploy to [Neocities][nc]. Default: `public`.
- `cleanup`: Boolean string (`true` or `false`). If `true`, `deploy-to-neocities` will destructively delete files found on [Neocoties][nc] not found in your `dist_dir`. Default: `false`.
### Outputs
None.
## See also ## See also
- [async-neocities](https://ghub.io/async-neocities): diffing engine used for action.
- [Neocities API Docs](https://neocities.org/api) - [Neocities API Docs](https://neocities.org/api)
- [neocities/neocities-node](https://github.com/neocities/neocities-node): Node api - [neocities/neocities-node](https://github.com/neocities/neocities-node): Node api
[qs]: https://ghub.io/qs
[nf]: https://ghub.io/node-fetch
[fd]: https://ghub.io/form-data
[nc]: https://neocities.org
[sec]: https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets

View File

@ -1,10 +1,10 @@
name: 'Deploy to Neocities' name: 'Deploy to Neocities'
description: 'Github Action to deplpoy a folder to Neocities.org' description: 'Efficiently deplpoy a folder to Neocities.org'
branding: branding:
icon: cat icon: aperture
color: yellow color: orange
inputs: inputs:
apiToken: # api token for site to deploy to api_token: # api token for site to deploy to
description: 'Neocities API token for site to deploy to' description: 'Neocities API token for site to deploy to'
required: true required: true
distDir: distDir:

View File

@ -6,8 +6,8 @@ const ms = require('ms')
const assert = require('nanoassert') const assert = require('nanoassert')
async function doDeploy () { async function doDeploy () {
const token = core.getInput('apiToken') const token = core.getInput('api_token')
const distDir = path.join(process.cwd(), core.getInput('distDir')) const distDir = path.join(process.cwd(), core.getInput('dist_dir'))
const cleanup = JSON.parse(core.getInput('cleanup')) const cleanup = JSON.parse(core.getInput('cleanup'))
assert(typeof cleanup === 'boolean', 'Cleanup input must be a boolean "true" or "false"') assert(typeof cleanup === 'boolean', 'Cleanup input must be a boolean "true" or "false"')

BIN
logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB