Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
djang0dev committed May 9, 2024
0 parents commit cdcd2d2
Show file tree
Hide file tree
Showing 22 changed files with 2,693 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'pipeline'
on:
push:
branches:
- 'main'
pull_request:
jobs:
ci:
name: 'ci'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install -g pnpm
- run: pnpm install
- run: pnpm run check
action:
name: 'action'
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install -g pnpm
- run: pnpm install
- run: pnpm run build
- uses: ./ # self
with:
upload: true
remove: true
storageName: ${{ secrets.BUNNY_STORAGE_NAME }}
storageEndpoint: "storage.bunnycdn.com"
storagePassword: ${{ secrets.BUNNY_STORAGE_PASSWORD }}
destination: "test/"
sourcePattern: "./e2e/test-dir/**/*.*"
apiKey: ${{ secrets.BUNNY_API_KEY }}
purgePullZone: true
pullZoneId: ${{ secrets.BUNNY_PULL_ZONE_ID }}
verbose: true
18 changes: 18 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'publish'
on:
release:
types: [published, edited]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
- uses: actions/setup-node@v4
- run: npm install -g pnpm
- run: pnpm install
- run: pnpm run build
- uses: aboutte/build-and-tag-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}
80 changes: 80 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
tmp
/out-tsc
.env
*.map.js
# dependencies
node_modules
__snapshots__
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
.pnpm-store
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

**/codegens/**/*.*
!**/codegens/**/*.gitkeep

.nx/cache
.swc

*.js.map
# moon
.moon/cache
.moon/docker

# The `outDir` for declarations

lib/
!templates/lib
# Build cache manifests
*.tsbuildinfo
tsconfig.node.tsbuildinfo
dist/

tsbuild/
# config loaded
vite.config.js

# secrets
*.secrets
*.env

styled-system
**/panda-ui/**/*.*
!**/panda-ui/**/package.json
!**/panda-ui/**/panda.config.ts
!**/panda-ui/**/moon.yml

kiwi-pivot-table.png
.copilotignore

trace-dir
.eslintcache
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Bunny.net Storage Deployer

[Bunny.net](https://bunny.net/) is a really cheap and functional content delivery platform that makes it easy to host content.

This action performs 3 operations.

- Removes all the files from storage.
- Uploads files and folders to storage.
- Purges an associated pull zone.

Each operation can be activated with their respective upload, remove and purge flags.

## Inputs

_All the inputs are required except `verbose`_

### `upload`

It will upload files and folders if true provided.

### `remove`

It will remove all the files from storage before uploading if "true" provided. storageZoneName and storagePassword inputs should be provided.

### `storageZoneName`

The name of storage zone where you are connecting to.

### `storageEndpoint`

The storage endpoint. Default value is storage.bunnycdn.com

### `storagePassword`

The storage password. It should be read and write capable.

### `sourcePattern`

The glob pattern to retrieve the files from, like `./dist/**/*.js`

### `destination`

The destination directory that should be uploaded to in the bunny storage zone. (Example: www). The destination should _not_ have a trailing / as in www/.

If you want to upload files to a nested directory, you can specify the path to the directory in the destination parameter. For example, if you want to upload files to a directory called assets inside the www directory, you can set the destination parameter to www/assets.

Note that the nested directory will be automatically created by the CDN if it does not already exist.

### `purgePullZone`

It will purge the pull zone if "true" provided. pullZoneId and apiKey inputs should be provided.

### `apiKey`

The API key. You can retrieve your api key from your profile settings

### `pullZoneId`

Pull zone ID. You can retrieve your pull zone id directly from here: `https://dash.bunny.net/cdn/PULL_ZONE_ID/general/hostnames`

### `verbose`

Log more stuffs.

## Example usage

```
- name: Deploy to Bunny.net
uses: djang0dev/bunnynet-storage-deploy@v0
with:
upload: true
remove: true
storageName: ${{ secrets.BUNNY_STORAGE_NAME }}
storageEndpoint: "storage.bunnycdn.com"
storagePassword: ${{ secrets.BUNNY_STORAGE_PASSWORD }}
destination: "test/"
sourcePattern: "./dist/**/*.*"
apiKey: ${{ secrets.BUNNY_API_KEY }}
purgePullZone: true
pullZoneId: ${{ secrets.BUNNY_PULL_ZONE_ID }}
verbose: true
```

# Refs
[ayeressian/bunnycdn-storage-deploy](https://github.com/ayeressian/bunnycdn-storage-deploy) - An equivalent, I got some issues with and I wanted to use a glob as source and learn some new effect tricks

# TODO
- [ ] Tests
- [ ] Convert as CLI if needed
63 changes: 63 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Bunny.net Storage Deployer"
author: "Kinane"
description: "A github action to deploy a glob pattern to bunny.net storage and flush the associated pull zone"
inputs:
upload:
description: >
It will upload files and folders if "true" provided. source, storageZoneName and storagePassword inputs should be provided.
type: boolean
default: false
remove:
description: >
It will remove all the files from storage before uploading if "true" provided.
type: boolean
default: false
storageName:
description: >
The name of storage zone where you are connecting to.
required: true
storageEndpoint:
description: >
The storage endpoint. Default value is storage.bunnycdn.com
default: storage.bunnycdn.com
storagePassword:
description: >
The storage password. It should be read and write capable.
required: true
sourcePattern:
description: >
The glob pattern to retrieve the files from, like `./dist/**/*.js`
required: true
destination:
description: >
The destination directory that should be uploaded to in the bunny storage zone. (Example: www). The destination should not have a trailing / as in www/.
If you want to upload files to a nested directory, you can specify the path to the directory in the destination parameter. For example, if you want to upload files to a directory called assets inside the www directory, you can set the destination parameter to www/assets.
Note that the nested directory will be automatically created by the CDN if it does not already exist.
required: true
purgePullZone:
description: >
It will purge the pull zone if "true" provided. pullZoneId and accessKey inputs should be provided.
type: boolean
default: false
apiKey:
description: >
You can retrieve your api key from your profile settings
required: true
pullZoneId:
description: >
You can retrieve your pull zone id directly from its url: https://dash.bunny.net/cdn/PULL_ZONE_ID/general/hostnames
required: true
verbose:
description: >
Verbose mode
required: false
default: false

runs:
using: "node20"
main: "dist/index.js"
branding:
icon: "upload-cloud"
color: "orange"
Loading

0 comments on commit cdcd2d2

Please sign in to comment.