Skip to content

Commit

Permalink
Merge pull request #32 from ayeressian/feature/storage-access-fix
Browse files Browse the repository at this point in the history
Fix remove and upload to storage
  • Loading branch information
ayeressian authored May 6, 2023
2 parents 3af7d3c + 36fc8df commit d09126d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
with:
source: "e2e/test-dir"
storageZoneName: "${{ secrets.STORAGE_NAME_TEST }}"
accessKey: "${{ secrets.STORAGE_KEY_TEST }}"
storagePassword: "${{ secrets.STORAGE_PASSWORD_TEST }}"
accessKey: "${{ secrets.ACCESS_KEY_TEST }}"
pullZoneId: "${{ secrets.ZONE_ID_TEST }}"
remove: "true"
purge: "true"
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ This action deploys selected directory to BunnyCDN storage.

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

### `storagePassword`

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

### `pullZoneId`

Necessary for purging pull zone.
Expand All @@ -36,10 +40,11 @@ It will remove the files from storage before uploading if "true" provided.

```
- name: Deploy to BunnyCDN
uses: ayeressian/[email protected].4
uses: ayeressian/[email protected].5
with:
source: "dist"
storageZoneName: "${{ secrets.STORAGE_NAME }}"
storagePassword: "${{ secrets.STORAGE_PASSWORD }}"
accessKey: "${{ secrets.STORAGE_KEY }}"
pullZoneId: "${{ secrets.ZONE_ID }}"
remove: "true"
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bunnycdn-storage-deploy",
"version": "1.1.4",
"version": "1.1.5",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ const run = async () => {
const storageZoneName = getInput("storageZoneName");
const storageEndpoint =
getInput("storageEndpoint") ?? "storage.bunnycdn.com";
const storagePassword = getInput("storagePassword");
const accessKey = getInput("accessKey");
const removeFlag = getInput("remove");
const pullZoneId = getInput("pullZoneId");
const purgeFlag = getInput("purge");

if (removeFlag === "true") {
info(`Deleting files from storage ${storageZoneName}`);
await remove(storageZoneName, accessKey, storageEndpoint);
await remove(storageZoneName, storagePassword, storageEndpoint);
}

if (storageZoneName && accessKey) {
if (storageZoneName && storagePassword) {
info(`Deploying ${source} folder/file to storage ${storageZoneName}`);
await uploader(source, storageZoneName, accessKey, storageEndpoint);
await uploader(source, storageZoneName, storagePassword, storageEndpoint);
}

if (pullZoneId && accessKey && purgeFlag) {
Expand Down
4 changes: 3 additions & 1 deletion src/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const remove = async (
accessKey: string,
storageEndpoint: string
): Promise<Response> => {
const response = await fetch(`https://${storageEndpoint}/${storageName}/`, {
const url = `https://${storageEndpoint}/${storageName}/`;
info(`Removing storage data with ${url}`);
const response = await fetch(url, {
method: "DELETE",
headers: {
AccessKey: accessKey,
Expand Down

0 comments on commit d09126d

Please sign in to comment.