GitHub action for deploying your static app to Bunny CDN π
βοΈ Uploads a given directory to a storage zone on Bunny
βοΈ Doesn't upload unchanged files
βοΈ Optionally deletes directories and files from your storage zone that doesn't exist in the specified directory-to-upload
βοΈ Optionally purges the cache of a given pull zone
βοΈ Optionally use concurrency to make it fast
The default action for this GitHub action, is that it uploads a given directory to a storage zone on Bunny. It also provides some extra features, which are listed under Feature flags. The required inputs could be different depending on the feature flag(s) that you enable. See for more info: Config.
Warnings (3)
β οΈ
- There is no option yet to rollback the changes that you can make with this GitHub Action. When something fails while running this action, you might have to manually fix it yourself.
- Ensure this action is not executed concurrently, otherwise it could result in unexpected errors and/or conflicting results. This might happen for example when you trigger this action on push. The action from the first push might still be running when you trigger the action again by the second push.
- Ensure this action isn't cancelled in the middle of a run, because that could result in a broken static app.
See for more examples: Examples
deploy:
runs-on: ubuntu-22.04
permissions:
contents: read
timeout-minutes: 5 # Depending on the size of your project
steps:
# Checkout repo
# Build your code or download build cache
- name: Deploy to Bunny
uses: R-J-dev/[email protected] # Select the version you wish to use
with:
access-key: ${{ secrets.BUNNY_ACCESS_KEY }}
directory-to-upload: "./build"
storage-endpoint: "https://storage.bunnycdn.com"
storage-zone-name: "my-storage-zone"
storage-zone-password: ${{ secrets.BUNNY_STORAGE_ZONE_PASSWORD }}
concurrency: "50" # Make sure to check the docs about concurrency before choosing this setting
enable-delete-action: true
enable-purge-pull-zone: true
pull-zone-id: "12345"
replication-timeout: "15000"
Key | Description |
---|---|
storage-zone-password |
Your bunny.net storage zone password, you can find this in the storage zone details page FTP & API Access. It should have read & write access, otherwise it can't upload files for example. This is necessary for edge storage API requests that needs to be made to Bunny. See for more info: authentication header in the docs. This will be read in src/config/config.ts, setSecret is used to mask it from logs (in case it will be logged by accident in your action run). Do not set this as plain text, save this as a secret in GitHub and reference here the secret id. See for more info: Using secrets in a workflow. In case you still have doubts, check the source code and pin this action to a full length commit SHA. See for more info: Using third-party actions about pinning an action to a full length commit SHA. |
directory-to-upload | The path to the directory that needs to be uploaded to Bunny. An absolute path is preferred, but otherwise the action will combine the GITHUB_WORKSPACE with this input. |
storage-endpoint | The storage API endpoint of your primary storage region. See for more info: Storage Endpoints. |
storage-zone-name | The name of your storage zone, to determine to which storage zone the static app needs to upload. |
concurrency | The maximum amount of concurrent actions (retrieving remote file info, deleting files, uploading files). For example this action can upload files using concurrency, but it depends on the GitHub runner and the API limit how much concurrent requests are possible. At Bunny the limit for concurrent uploads per storage zone seems to be 50. See for more info: Edge Storage API Limits. |
Key | Description |
---|---|
access-key |
Your bunny.net storage zone API key. This is necessary for the network requests that needs to be made to Bunny. See for more info: authentication header in the docs. This will be read in src/config/config.ts, setSecret is used to mask it from logs (in case it will be logged by accident in your action run). Do not set this as plain text, save this as a secret in GitHub and reference here the secret id. See for more info: Using secrets in a workflow. In case you still have doubts, check the source code and pin this action to a full length commit SHA. See for more info: Using third-party actions about pinning an action to a full length commit SHA. |
pull-zone-id | The pull zone id is required for purging the cache. |
replication-timeout | The amount of milliseconds to wait before purging the cache. Unfortunately Bunny doesn't provide an api endpoint yet to check if the replicated storage zones are on the latest version (equal to main storage zone). See for more info: Understanding Geo-Replication. As you can read in the before mentioned link, an uploaded file should be replicated to other regions within a couple of seconds. So I think it should be safe to set this to 15000 milliseconds (15 seconds), but check what works best for you. |
Key | Description |
---|---|
target-directory | The directory path where the files from directory-to-upload needs to be uploaded to inside your storage zone. When the target-directory hasn't been passed or is an empty string, then the directory-to-upload will be uploaded to the root of your storage zone. |
Key | Description |
---|---|
enable-delete-action | Removes directories and files from your storage zone that doesn't exists or doesn't have read access in the local specified directory-to-upload. |
enable-purge-pull-zone | Purges the cache of the given pull-zone-id when all actions have finished. |
disable-upload | Disables the default upload action. This makes it possible to run for example the delete and/or purge action only. |
disable-type-validation | Disables type validation when the action retrieves file info. You probably will not need to disable the type validation, but in case Bunny changes their API and the action doesn't break due to the changes, you might choose to temporary disable the type validation. In the mean time a new PR can be created to fix this. |
deploy:
runs-on: ubuntu-22.04
permissions:
contents: read
timeout-minutes: 5 # Depending on the size of your project
steps:
# Checkout repo
# Build your code or download build cache
- name: Deploy to Bunny
uses: R-J-dev/[email protected] # Select the version you wish to use
with:
storage-zone-password: ${{ secrets.BUNNY_STORAGE_ZONE_PASSWORD }}
directory-to-upload: "./build"
storage-endpoint: "https://storage.bunnycdn.com"
storage-zone-name: "my-storage-zone"
concurrency: "50" # Make sure to check the docs about concurrency before choosing this setting
deploy:
runs-on: ubuntu-22.04
permissions:
contents: read
timeout-minutes: 5 # Depending on the size of your project
steps:
# Checkout repo
# Build your code or download build cache
- name: Deploy to Bunny
uses: R-J-dev/[email protected] # Select the version you wish to use
with:
access-key: ${{ secrets.BUNNY_ACCESS_KEY }}
directory-to-upload: "./build"
storage-endpoint: "https://storage.bunnycdn.com"
storage-zone-name: "my-storage-zone"
storage-zone-password: ${{ secrets.BUNNY_STORAGE_ZONE_PASSWORD }}
concurrency: "50" # Make sure to check the docs about concurrency before choosing this setting
enable-delete-action: true
enable-purge-pull-zone: true
pull-zone-id: "12345"
replication-timeout: "15000"
purge:
runs-on: ubuntu-22.04
permissions:
contents: read
timeout-minutes: 5 # Depending on the size of your project
steps:
# Checkout repo
# Build your code or download build cache
- name: Purge pull zone
uses: R-J-dev/[email protected] # Select the version you wish to use
with:
access-key: ${{ secrets.BUNNY_ACCESS_KEY }}
disable-upload: true
enable-purge-pull-zone: true
pull-zone-id: "12345"
replication-timeout: "15000"
The list files API endpoint from Bunny is used to do checksum comparisons with all the local files (also nested files in child directories) that are located in the given directory-to-upload
. This way the action knows if a file has been changed or not.
Note: The process of checking which files are unchanged is always enabled when you choose to upload or delete files with this action. In case deleting files is enabled, but
disable-upload
is true, unchanged files are still logged.
Files from the list files API endpoint from Bunny, including those in nested directories, are checked for local read access using Node.js's access method. Files without local read access are marked as unknown remote files, because they either doesn't exist or doesn't have read access. When a local file doesn't have read access it also couldn't be uploaded, so it would make sense to delete it from the storage zone. If enable-delete-action
is set to true, these files will be deleted from the storage zone.
Note: The process of checking which files are unknown is always enabled when you choose to upload or delete files with this action. In case uploading files is enabled, but
enable-delete-action
is false, unknown or unreadable files are still logged.