mirror of
https://github.com/bcomnes/deploy-to-neocities.git
synced 2026-01-17 06:56:30 +00:00
Compare commits
55 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de4676a924 | ||
|
|
79d75215d1 | ||
|
|
d6c0f848a3 | ||
|
|
11cf75df91 | ||
|
|
4d15d7c9f2 | ||
|
|
39345a2e6f | ||
|
|
cb049fd7b8 | ||
|
|
b488452950 | ||
|
|
1016238f73 | ||
|
|
d52115bd89 | ||
|
|
93d216da0c | ||
|
|
0d13efc34c | ||
|
|
9d97056ec2 | ||
|
|
34a387ef17 | ||
|
|
64cd6c4a38 | ||
|
|
9a0a1dcd38 | ||
|
|
a98f3aead4 | ||
|
|
039f475bcb | ||
|
|
b66cd2f439 | ||
|
|
08817e531c | ||
|
|
692b031118 | ||
|
|
a1ae452c40 | ||
|
|
c072c98ce4 | ||
|
|
308934ebd2 | ||
|
|
3b9c0ff6a8 | ||
|
|
51ec937eb8 | ||
|
|
6ad0ab0d14 | ||
|
|
f02d52685d | ||
|
|
7c11b664c6 | ||
|
|
20286ea2e1 | ||
|
|
2eafa119db | ||
|
|
136098ad51 | ||
|
|
5761b44f4d | ||
|
|
e062c69fd8 | ||
|
|
f0b7afe72c | ||
|
|
6440dab52a | ||
|
|
70b264bcb3 | ||
|
|
75401fb61d | ||
|
|
60adbf96af | ||
|
|
68d0158045 | ||
|
|
105af8d6d9 | ||
|
|
0836ded28a | ||
|
|
e1376e6631 | ||
|
|
2d1e970973 | ||
|
|
4c76eb6aac | ||
|
|
e6592bbaff | ||
|
|
180c4df293 | ||
|
|
8f5b34d768 | ||
|
|
15eb88d483 | ||
|
|
c320837978 | ||
|
|
0e06b4e2e9 | ||
|
|
c636648753 | ||
|
|
7b14798c89 | ||
|
|
f9a550fd47 | ||
|
|
7fc09bc1c3 |
6
.github/dependabot.yml
vendored
6
.github/dependabot.yml
vendored
@ -10,9 +10,13 @@ updates:
|
|||||||
# Check the npm registry for updates every day (weekdays)
|
# Check the npm registry for updates every day (weekdays)
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
groups:
|
||||||
|
typescript:
|
||||||
|
patterns:
|
||||||
|
- "typescript"
|
||||||
|
- "@voxpelli/tsconfig"
|
||||||
# Enable updates to github actions
|
# Enable updates to github actions
|
||||||
- package-ecosystem: "github-actions"
|
- package-ecosystem: "github-actions"
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
|
|
||||||
|
|||||||
8
.github/workflows/neocities.yml
vendored
8
.github/workflows/neocities.yml
vendored
@ -19,11 +19,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
# Set up any tools and build steps here
|
# Set up any tools and build steps here
|
||||||
# This example uses a Node.js toolchain to build a site
|
# This example uses a Node.js toolchain to build a site
|
||||||
- name: Use Node.js
|
- name: Use Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.node_version }}
|
node-version: ${{ env.node_version }}
|
||||||
- run: npm i
|
- run: npm i
|
||||||
@ -32,7 +32,9 @@ jobs:
|
|||||||
- name: Deploy to neocities
|
- name: Deploy to neocities
|
||||||
uses: bcomnes/deploy-to-neocities@master # dont use master in production
|
uses: bcomnes/deploy-to-neocities@master # dont use master in production
|
||||||
with:
|
with:
|
||||||
api_token: ${{ secrets.NEOCITIES_API_TOKEN }}
|
api_key: ${{ secrets.NEOCITIES_API_TOKEN }}
|
||||||
cleanup: true
|
cleanup: true
|
||||||
dist_dir: public
|
dist_dir: public
|
||||||
protected_files: 'dropbox/*'
|
protected_files: 'dropbox/*'
|
||||||
|
neocities_supporter: true # set this to true if you have a supporter account and want to bypass unsuported files filter.
|
||||||
|
preview_before_deploy: true
|
||||||
|
|||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@ -19,11 +19,11 @@ jobs:
|
|||||||
version_and_release:
|
version_and_release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
# fetch full history so things like auto-changelog work properly
|
# fetch full history so things like auto-changelog work properly
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.node_version }}
|
node-version: ${{ env.node_version }}
|
||||||
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
|
# setting a registry enables the NODE_AUTH_TOKEN env variable where we can set an npm token. REQUIRED
|
||||||
|
|||||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -15,9 +15,9 @@ jobs:
|
|||||||
node: [lts/*]
|
node: [lts/*]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- name: Use Node.js ${{ matrix.node }}
|
- name: Use Node.js ${{ matrix.node }}
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
- run: npm i
|
- run: npm i
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ public
|
|||||||
node_modules
|
node_modules
|
||||||
tmp_modules
|
tmp_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
coverage
|
||||||
|
|||||||
57
CHANGELOG.md
57
CHANGELOG.md
@ -7,7 +7,62 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
||||||
|
|
||||||
## [v2.0.4](https://github.com/bcomnes/deploy-to-neocities/compare/v2.0.3...v2.0.4)
|
## [v3.0.4](https://github.com/bcomnes/deploy-to-neocities/compare/v3.0.3...v3.0.4)
|
||||||
|
|
||||||
|
### Merged
|
||||||
|
|
||||||
|
- chore(deps): bump minimatch from 10.0.1 to 10.0.3 [`#224`](https://github.com/bcomnes/deploy-to-neocities/pull/224)
|
||||||
|
|
||||||
|
### Commits
|
||||||
|
|
||||||
|
- Merge pull request #225 from bcomnes/dependabot/npm_and_yarn/async-neocities-4.1.2 [`692b031`](https://github.com/bcomnes/deploy-to-neocities/commit/692b031118b324f3c28f2204ff18882edb9c53af)
|
||||||
|
- chore(deps): bump async-neocities from 4.1.1 to 4.1.2 [`a1ae452`](https://github.com/bcomnes/deploy-to-neocities/commit/a1ae452c40f056b6cead68ed5d914245860ab45e)
|
||||||
|
|
||||||
|
## [v3.0.3](https://github.com/bcomnes/deploy-to-neocities/compare/v3.0.2...v3.0.3) - 2025-06-01
|
||||||
|
|
||||||
|
### Merged
|
||||||
|
|
||||||
|
- Add my own website in README.md [`#222`](https://github.com/bcomnes/deploy-to-neocities/pull/222)
|
||||||
|
- chore(deps-dev): bump typescript from 5.7.3 to 5.8.2 [`#217`](https://github.com/bcomnes/deploy-to-neocities/pull/217)
|
||||||
|
- chore(deps-dev): bump esbuild from 0.24.2 to 0.25.0 [`#213`](https://github.com/bcomnes/deploy-to-neocities/pull/213)
|
||||||
|
- chore(deps-dev): bump neostandard from 0.11.9 to 0.12.0 [`#211`](https://github.com/bcomnes/deploy-to-neocities/pull/211)
|
||||||
|
|
||||||
|
### Commits
|
||||||
|
|
||||||
|
- Update async-neocities [`51ec937`](https://github.com/bcomnes/deploy-to-neocities/commit/51ec937eb84fa6beae055593f8e286e7d49d1d1e)
|
||||||
|
- Merge pull request #221 from bcomnes/dependabot/npm_and_yarn/npm-run-all2-8.0.1 [`7c11b66`](https://github.com/bcomnes/deploy-to-neocities/commit/7c11b664c6b9ed5b7d72def8047f539b2f2205a9)
|
||||||
|
- More example comments [`5761b44`](https://github.com/bcomnes/deploy-to-neocities/commit/5761b44f4df0408697ca3c9438cf8f7ae8df9628)
|
||||||
|
|
||||||
|
## [v3.0.2](https://github.com/bcomnes/deploy-to-neocities/compare/v3.0.1...v3.0.2) - 2024-12-09
|
||||||
|
|
||||||
|
### Merged
|
||||||
|
|
||||||
|
- chore(deps): bump async-neocities from 4.0.4 to 4.1.0 [`#210`](https://github.com/bcomnes/deploy-to-neocities/pull/210)
|
||||||
|
|
||||||
|
## [v3.0.1](https://github.com/bcomnes/deploy-to-neocities/compare/v3.0.0...v3.0.1) - 2024-11-28
|
||||||
|
|
||||||
|
### Merged
|
||||||
|
|
||||||
|
- chore(deps): bump async-neocities from 4.0.3 to 4.0.4 [`#209`](https://github.com/bcomnes/deploy-to-neocities/pull/209)
|
||||||
|
- fixed a typo in README.md [`#208`](https://github.com/bcomnes/deploy-to-neocities/pull/208)
|
||||||
|
- chore(deps-dev): bump typescript from 5.6.3 to 5.7.2 [`#207`](https://github.com/bcomnes/deploy-to-neocities/pull/207)
|
||||||
|
- Add my website https://jefbecker.com/ to the list. [`#206`](https://github.com/bcomnes/deploy-to-neocities/pull/206)
|
||||||
|
|
||||||
|
### Commits
|
||||||
|
|
||||||
|
- Update README.md [`15eb88d`](https://github.com/bcomnes/deploy-to-neocities/commit/15eb88d4831e8b3170195c1e2b468e8ab3a9703d)
|
||||||
|
|
||||||
|
## [v3.0.0](https://github.com/bcomnes/deploy-to-neocities/compare/v2.0.4...v3.0.0) - 2024-11-19
|
||||||
|
|
||||||
|
### Merged
|
||||||
|
|
||||||
|
- chore(deps-dev): bump npm-run-all2 from 6.2.6 to 7.0.1 [`#205`](https://github.com/bcomnes/deploy-to-neocities/pull/205)
|
||||||
|
|
||||||
|
### Commits
|
||||||
|
|
||||||
|
- **Breaking change:** Update to the latest async-neocities 4.0 [`7b14798`](https://github.com/bcomnes/deploy-to-neocities/commit/7b14798c892f2494466bc72d5402c85801f75341)
|
||||||
|
|
||||||
|
## [v2.0.4](https://github.com/bcomnes/deploy-to-neocities/compare/v2.0.3...v2.0.4) - 2024-10-07
|
||||||
|
|
||||||
### Merged
|
### Merged
|
||||||
|
|
||||||
|
|||||||
25
README.md
25
README.md
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
Efficiently deploy a website to [Neocities][nc] using [Github actions](https://github.com/features/actions). Uses content aware diffing to only update files that changed.
|
Efficiently deploy a website to [Neocities][nc] using [Github actions](https://github.com/features/actions). Uses content aware diffing to only update files that changed.
|
||||||
|
|
||||||
|
Alternatively, you can use the bin helper in [async-neocities](https://github.com/bcomnes/async-neocities) to deploy to neocities locally from your own machine as well as in CI.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -30,23 +32,29 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
# The checkout step copies your repo into the action runner. Important!
|
||||||
|
- uses: actions/checkout@v4
|
||||||
# Set up any tools and build steps here
|
# Set up any tools and build steps here
|
||||||
# This example uses a Node.js toolchain to build a site
|
# This example uses a Node.js toolchain to build a site
|
||||||
|
# If you don't need Node.js to build your site, you can omit this.
|
||||||
- name: Use Node.js
|
- name: Use Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: lts/*
|
node-version: lts/*
|
||||||
|
# If you have a different build process, replace this with your own build steps
|
||||||
- name: Install deps and build
|
- name: Install deps and build
|
||||||
run: |
|
run: |
|
||||||
npm i
|
npm i
|
||||||
npm run build
|
npm run build
|
||||||
# When the dist_dir is ready, deploy it to neocities
|
# When the dist_dir is ready, deploy it to neocities
|
||||||
|
# Here we deploy the folder named `public`
|
||||||
- name: Deploy to neocities
|
- name: Deploy to neocities
|
||||||
uses: bcomnes/deploy-to-neocities@v2
|
uses: bcomnes/deploy-to-neocities@v3
|
||||||
with:
|
with:
|
||||||
api_token: ${{ secrets.NEOCITIES_API_TOKEN }}
|
api_key: ${{ secrets.NEOCITIES_API_TOKEN }}
|
||||||
cleanup: false
|
cleanup: false
|
||||||
|
neocities_supporter: false # set this to true if you have a supporter account and want to bypass unsuported files filter.
|
||||||
|
preview_before_deploy: true # print a deployment plan prior to waiting for files to upload.
|
||||||
dist_dir: public
|
dist_dir: public
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -61,7 +69,7 @@ You'll need the API token for your site. Go to:
|
|||||||
https://neocities.org/settings/{{your-sitename}}#api_key
|
https://neocities.org/settings/{{your-sitename}}#api_key
|
||||||
```
|
```
|
||||||
|
|
||||||
Get your site's API token. In your GitHub repository, set a [secret][sec] 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.
|
Retreive your site's API token from Neocities. In your GitHub repository, set a [secret][sec] 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. The setting (as of writing) lives in Repository > Settings > Security > Secrets and Variables > Actions > Repository secrets.
|
||||||
|
|
||||||
During your workflow, generate the files you want to deploy to [Neocities][nc] 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.
|
During your workflow, generate the files you want to deploy to [Neocities][nc] 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.
|
||||||
|
|
||||||
@ -71,9 +79,11 @@ You most likely only want to run this on the `master` branch so that only change
|
|||||||
|
|
||||||
### Inputs
|
### Inputs
|
||||||
|
|
||||||
- `api_token` (**REQUIRED**): The API token for your [Neocities][nc] website to deploy to.
|
- `api_key` (**REQUIRED**): The API token for your [Neocities][nc] website to deploy to.
|
||||||
- `dist_dir`: The directory to deploy to [Neocities][nc]. 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.
|
- `dist_dir`: The directory to deploy to [Neocities][nc]. 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.
|
||||||
|
- `neocities_supporter`: Set this to `true` if you have a paid neocities account and want to bypass the [unsupported files filter](https://neocities.org/site_files/allowed_types).
|
||||||
- `cleanup`: Boolean string (`true` or `false`). If `true`, `deploy-to-neocities` will destructively delete files found on [Neocities][nc] not found in your `dist_dir`. Default: `false`.
|
- `cleanup`: Boolean string (`true` or `false`). If `true`, `deploy-to-neocities` will destructively delete files found on [Neocities][nc] not found in your `dist_dir`. Default: `false`.
|
||||||
|
- `preview_before_deploy`: Boolean string (`true` or `false`). If `true`, `deploy-to-neocities` will print a preview of the files that will be uploaded and deleted. Default: `true`.
|
||||||
- `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](https://github.com/isaacs/minimatch) against remote neocities file paths. Protected files can still be updated.
|
- `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](https://github.com/isaacs/minimatch) against remote neocities file paths. Protected files can still be updated.
|
||||||
|
|
||||||
### Outputs
|
### Outputs
|
||||||
@ -144,6 +154,9 @@ None.
|
|||||||
- https://sacred.neocities.org/ (https://github.com/M-Valentino/sacredOS)
|
- https://sacred.neocities.org/ (https://github.com/M-Valentino/sacredOS)
|
||||||
- https://lenp.net/ (https://github.com/Len42/web-site)
|
- https://lenp.net/ (https://github.com/Len42/web-site)
|
||||||
- <https://punkfairie.net> (<https://github.com/punkfairie/punkfairie-site>)
|
- <https://punkfairie.net> (<https://github.com/punkfairie/punkfairie-site>)
|
||||||
|
- https://github.com/jefbecker/jefbecker.com ([jefbecker.com](https://jefbecker.com))
|
||||||
|
- https://github.com/MymeType/personal-website ([mymetype.neocities.org](https://mymetype.neocities.org/))
|
||||||
|
- https://github.com/oceanthunder/oceanthunder.github.io ([oceanthunder.dev](https://www.oceanthunder.dev))
|
||||||
- [See more!](https://github.com/bcomnes/deploy-to-neocities/network/dependents)
|
- [See more!](https://github.com/bcomnes/deploy-to-neocities/network/dependents)
|
||||||
- ...PR your site when you set it up!
|
- ...PR your site when you set it up!
|
||||||
|
|
||||||
|
|||||||
20
action.yml
20
action.yml
@ -4,20 +4,32 @@ branding:
|
|||||||
icon: aperture
|
icon: aperture
|
||||||
color: orange
|
color: orange
|
||||||
inputs:
|
inputs:
|
||||||
api_token: # api token for site to deploy to
|
api_key: # api token for site to deploy to
|
||||||
description: 'Neocities API token for site to deploy to'
|
description: 'Neocities API key for site to deploy to'
|
||||||
required: true
|
required: true
|
||||||
dist_dir:
|
dist_dir:
|
||||||
description: 'Local folder to deploy to neocities'
|
description: 'Local folder to deploy to neocities'
|
||||||
default: 'public'
|
default: 'public'
|
||||||
required: true
|
required: true
|
||||||
|
neocities_supporter:
|
||||||
|
description: 'Set to true if you are a Neocities supporter to bypass file type upload restrictions'
|
||||||
|
default: 'false'
|
||||||
|
required: true
|
||||||
cleanup:
|
cleanup:
|
||||||
description: Delete orphaned files on neocities that don't exist in distDir
|
description: Delete orphaned files on neocities that don't exist in distDir
|
||||||
default: false
|
default: 'false'
|
||||||
required: true
|
required: true
|
||||||
|
preview_before_deploy:
|
||||||
|
description: 'Set to true if you want to print deploy preview stats prior to deploying.'
|
||||||
|
default: 'true'
|
||||||
|
required: false
|
||||||
protected_files:
|
protected_files:
|
||||||
description: A glob string that prevents matched files from ever being deleted.
|
description: A glob string that prevents matched files from ever being deleted.
|
||||||
required: false
|
required: false
|
||||||
|
api_token: # api token for site to deploy to
|
||||||
|
description: 'Neocities API key for site to deploy to'
|
||||||
|
required: false
|
||||||
|
deprecationMessage: 'api_token is deprecated, use api_key instead'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.cjs'
|
||||||
|
|||||||
36198
dist/index.js → dist/index.cjs
vendored
36198
dist/index.js → dist/index.cjs
vendored
File diff suppressed because one or more lines are too long
7
dist/index.cjs.map
vendored
Normal file
7
dist/index.cjs.map
vendored
Normal file
File diff suppressed because one or more lines are too long
7
dist/index.js.map
vendored
7
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
9039
dist/meta.json
vendored
Normal file
9039
dist/meta.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
eslint.config.js
Normal file
8
eslint.config.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
|
||||||
|
|
||||||
|
export default neostandard({
|
||||||
|
ignores: [
|
||||||
|
...resolveIgnoresFromGitignore(),
|
||||||
|
'dist'
|
||||||
|
],
|
||||||
|
})
|
||||||
113
index.js
113
index.js
@ -1,57 +1,84 @@
|
|||||||
const core = require('@actions/core')
|
import core from '@actions/core'
|
||||||
// const github = require('@actions/github')
|
import {
|
||||||
const Neocities = require('async-neocities')
|
NeocitiesAPIClient,
|
||||||
const path = require('path')
|
printDeployText,
|
||||||
const ms = require('ms')
|
printPreviewText,
|
||||||
const assert = require('webassert').default
|
printResultsErrorDump,
|
||||||
const fsp = require('fs').promises
|
SimpleTimer
|
||||||
const { minimatch } = require('minimatch')
|
} from 'async-neocities'
|
||||||
const { stackWithCauses } = require('pony-cause')
|
import path from 'node:path'
|
||||||
|
import assert from 'node:assert'
|
||||||
|
import fs from 'node:fs/promises'
|
||||||
|
import { minimatch } from 'minimatch'
|
||||||
|
|
||||||
let cleanup
|
async function run () {
|
||||||
|
const key = core.getInput('api_key') || core.getInput('api_token')
|
||||||
async function doDeploy () {
|
|
||||||
const token = core.getInput('api_token')
|
|
||||||
const distDir = path.join(process.cwd(), core.getInput('dist_dir'))
|
const distDir = path.join(process.cwd(), core.getInput('dist_dir'))
|
||||||
cleanup = JSON.parse(core.getInput('cleanup'))
|
const cleanup = JSON.parse(core.getInput('cleanup'))
|
||||||
|
const neocitiesSupporter = JSON.parse(core.getInput('neocities_supporter'))
|
||||||
|
const previewDeploy = JSON.parse(core.getInput('preview_before_deploy'))
|
||||||
const protectedFilesGlob = core.getInput('protected_files')
|
const protectedFilesGlob = core.getInput('protected_files')
|
||||||
|
|
||||||
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"')
|
||||||
const stat = await fsp.stat(distDir)
|
assert(typeof neocitiesSupporter === 'boolean', '`neocities_supporter` input must be a boolean "true" or "false"')
|
||||||
assert(stat.isDirectory(), 'dist_dir must be a directory that exists')
|
assert(typeof previewDeploy === 'boolean', '`preview_before_deploy` input must be a boolean "true" or "false"')
|
||||||
|
|
||||||
const client = new Neocities(token)
|
const stat = await fs.stat(distDir)
|
||||||
|
|
||||||
const deployOpts = {
|
assert(stat.isDirectory(), '`dist_dir` input must be a path to a directory that exists')
|
||||||
cleanup,
|
|
||||||
statsCb: Neocities.statsHandler()
|
const client = new NeocitiesAPIClient(key)
|
||||||
|
|
||||||
|
if (previewDeploy) {
|
||||||
|
const previewTimer = new SimpleTimer()
|
||||||
|
console.log('Running deploy preview prior to deployment...\n\n')
|
||||||
|
|
||||||
|
const diff = await client.previewDeploy({
|
||||||
|
directory: distDir,
|
||||||
|
includeUnsupportedFiles: neocitiesSupporter,
|
||||||
|
protectedFileFilter: protectedFilesGlob ? minimatch.filter(protectedFilesGlob) : undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
previewTimer.stop()
|
||||||
|
|
||||||
|
printPreviewText({
|
||||||
|
diff,
|
||||||
|
timer: previewTimer,
|
||||||
|
cleanup,
|
||||||
|
includeUnsupportedFiles: neocitiesSupporter
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protectedFilesGlob) deployOpts.protectedFileFilter = minimatch.filter(protectedFilesGlob)
|
const deployTimer = new SimpleTimer()
|
||||||
|
console.log('Deploying to Neocities...')
|
||||||
|
|
||||||
const stats = await client.deploy(distDir, deployOpts)
|
const results = await client.deploy({
|
||||||
|
directory: distDir,
|
||||||
|
cleanup,
|
||||||
|
includeUnsupportedFiles: neocitiesSupporter,
|
||||||
|
protectedFileFilter: protectedFilesGlob ? minimatch.filter(protectedFilesGlob) : undefined
|
||||||
|
})
|
||||||
|
|
||||||
console.log(`Deployed to Neocities in ${ms(stats.time)}:`)
|
deployTimer.stop()
|
||||||
console.log(` Uploaded ${stats.filesToUpload.length} files`)
|
|
||||||
console.log(` ${cleanup ? 'Deleted' : 'Orphaned'} ${stats.filesToDelete.length} files`)
|
if (results.errors.length > 0) {
|
||||||
console.log(` Skipped ${stats.filesSkipped.length} files`)
|
printResultsErrorDump({
|
||||||
console.log(` ${stats.protectedFiles.length} protected files:`)
|
results,
|
||||||
if (stats.protectedFiles.length) {
|
timer: deployTimer
|
||||||
console.log(stats.protectedFiles)
|
})
|
||||||
|
core.setFailed('The deploy completed with errors.')
|
||||||
|
} else {
|
||||||
|
printDeployText({
|
||||||
|
results,
|
||||||
|
timer: deployTimer,
|
||||||
|
cleanup,
|
||||||
|
includeUnsupportedFiles: neocitiesSupporter
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doDeploy().catch(err => {
|
run().catch(err => {
|
||||||
console.error(stackWithCauses(err))
|
console.log('Unexpected error/throw during deployment:\n\n')
|
||||||
if (err.stats) {
|
console.dir(err, { colors: true, depth: 999 })
|
||||||
console.log('Files to upload: ')
|
core.setFailed(err instanceof Error ? err.message : `An unexpected error occurred during deployment: ${err}`)
|
||||||
console.dir(err.stats.filesToUpload, { colors: true, depth: 999 })
|
|
||||||
|
|
||||||
if (cleanup) {
|
|
||||||
console.log('Files to delete: ')
|
|
||||||
console.dir(err.stats.filesToDelete, { colors: true, depth: 999 })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
core.setFailed(err.message)
|
|
||||||
})
|
})
|
||||||
|
|||||||
37
package.json
37
package.json
@ -1,32 +1,32 @@
|
|||||||
{
|
{
|
||||||
"name": "deploy-to-neocities",
|
"name": "deploy-to-neocities",
|
||||||
"description": "Github Action to deplpoy a folder to Neocities.org",
|
"description": "Github Action to deplpoy a folder to Neocities.org",
|
||||||
"version": "2.0.4",
|
"version": "3.0.4",
|
||||||
"author": "Bret Comnes <bcomnes@gmail.com> (https://bret.io/)",
|
"author": "Bret Comnes <bcomnes@gmail.com> (https://bret.io/)",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/bcomnes/deploy-to-neocities/issues"
|
"url": "https://github.com/bcomnes/deploy-to-neocities/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "1.11.1",
|
"@actions/core": "2.0.2",
|
||||||
"async-neocities": "2.1.6",
|
"async-neocities": "4.1.2",
|
||||||
"minimatch": "10.0.1",
|
"minimatch": "10.1.1"
|
||||||
"ms": "2.1.3",
|
|
||||||
"pony-cause": "^2.1.4",
|
|
||||||
"webassert": "3.0.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@voxpelli/tsconfig": "^16.1.0",
|
||||||
"top-bun": "^10.0.0",
|
"top-bun": "^10.0.0",
|
||||||
"auto-changelog": "^2.0.0",
|
"auto-changelog": "^2.0.0",
|
||||||
"dependency-check": "^4.1.0",
|
|
||||||
"gh-release": "^7.0.0",
|
"gh-release": "^7.0.0",
|
||||||
"npm-run-all2": "^6.0.0",
|
"npm-run-all2": "^8.0.1",
|
||||||
"standard": "^17.0.0",
|
"neostandard": "^0.12.0",
|
||||||
"esbuild": "^0.24.0"
|
"c8": "^10.0.0",
|
||||||
|
"esbuild": "~0.27.1",
|
||||||
|
"typescript": "~5.9.3"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/bcomnes/deploy-to-neocities#readme",
|
"homepage": "https://github.com/bcomnes/deploy-to-neocities#readme",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -34,23 +34,20 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run clean && run-p build:*",
|
"build": "npm run clean && run-p build:*",
|
||||||
"build:action": "rm -rf dist && esbuild index.js --bundle --platform=node --target=node16 --sourcemap=external --outdir=dist",
|
"build:action": "rm -rf dist && esbuild index.js --bundle --platform=node --sourcemap=external --outdir=dist --metafile=dist/meta.json --out-extension:.js=.cjs",
|
||||||
"build:site": "tb --src . --dest public",
|
"build:site": "tb --src . --dest public --ignore dist,coverage",
|
||||||
|
"dist-pkg": "echo \"{ \\\"type\\\": \\\"commonjs\\\" }\" > dist/package.json",
|
||||||
"clean": "rm -rf public && mkdir -p public",
|
"clean": "rm -rf public && mkdir -p public",
|
||||||
"release": "git push --follow-tags && gh-release -y",
|
"release": "git push --follow-tags && gh-release -y",
|
||||||
"start": "npm run watch",
|
"start": "npm run watch",
|
||||||
"test": "run-s test:*",
|
"test": "run-s test:*",
|
||||||
"test:deps": "dependency-check . --no-dev --no-peer",
|
"test:lint": "eslint",
|
||||||
"test:standard": "standard",
|
"test:tsc": "tsc",
|
||||||
|
"test:node": "c8 node --test",
|
||||||
"version": "run-s version:*",
|
"version": "run-s version:*",
|
||||||
"version:build": "npm run build:action && git add dist",
|
"version:build": "npm run build:action && git add dist",
|
||||||
"version:changelog": "auto-changelog -p --template keepachangelog auto-changelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md",
|
"version:changelog": "auto-changelog -p --template keepachangelog auto-changelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md",
|
||||||
"watch": "npm run clean && run-p watch:*",
|
"watch": "npm run clean && run-p watch:*",
|
||||||
"watch:site": "npm run build:site -- -w"
|
"watch:site": "npm run build:site -- -w"
|
||||||
},
|
|
||||||
"standard": {
|
|
||||||
"ignore": [
|
|
||||||
"dist"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
test.js
7
test.js
@ -1,5 +1,6 @@
|
|||||||
const tap = require('tap')
|
import assert from 'node:assert'
|
||||||
|
import test from 'node:test'
|
||||||
|
|
||||||
tap.test('test', async t => {
|
test('test', async _t => {
|
||||||
t.ok(true)
|
assert.ok(true)
|
||||||
})
|
})
|
||||||
|
|||||||
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"extends": "@voxpelli/tsconfig/node20.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"**/*"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"public",
|
||||||
|
"dist"
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user