Skip to content

Commit

Permalink
Merge pull request #31 from ayeressian/feature/manual-action-run
Browse files Browse the repository at this point in the history
Add workflow dispatch to github action
  • Loading branch information
ayeressian authored May 5, 2023
2 parents e40ad66 + 5507a8b commit 3af7d3c
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- feature/*
workflow_dispatch:

jobs:
cd:
Expand All @@ -18,6 +19,5 @@ jobs:
storageZoneName: "${{ secrets.STORAGE_NAME_TEST }}"
accessKey: "${{ secrets.STORAGE_KEY_TEST }}"
pullZoneId: "${{ secrets.ZONE_ID_TEST }}"
pullZoneAccessKey: "${{ secrets.PULL_ZONE_KEY_TEST }}"
remove: "true"
purge: "true"
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ The storage endpoint. Default value is storage.bunnycdn.com

Necessary for purging pull zone.

### `pullZoneAccessKey`

Necessary for purging pull zone.

### `purge`

It will purge the pull zone if true. pullZoneId and pullZoneAccessKey should be provided.
Expand All @@ -40,13 +36,12 @@ It will remove the files from storage before uploading if "true" provided.

```
- name: Deploy to BunnyCDN
uses: ayeressian/[email protected].3
uses: ayeressian/[email protected].4
with:
source: "dist"
storageZoneName: "${{ secrets.STORAGE_NAME }}"
accessKey: "${{ secrets.STORAGE_KEY }}"
pullZoneId: "${{ secrets.ZONE_ID }}"
pullZoneAccessKey: "${{ secrets.PULL_ZONE_KEY }}"
remove: "true"
purge: "true"
```
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.3",
"version": "1.1.4",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const run = async () => {
const accessKey = getInput("accessKey");
const removeFlag = getInput("remove");
const pullZoneId = getInput("pullZoneId");
const pullZoneAccessKey = getInput("pullZoneAccessKey");
const purgeFlag = getInput("purge");

if (removeFlag === "true") {
Expand All @@ -29,9 +28,9 @@ const run = async () => {
await uploader(source, storageZoneName, accessKey, storageEndpoint);
}

if (pullZoneId && pullZoneAccessKey && purgeFlag) {
if (pullZoneId && accessKey && purgeFlag) {
info(`Purging pull zone with the id ${pullZoneId}`);
await purge(pullZoneId, pullZoneAccessKey);
await purge(pullZoneId, accessKey);
}
} catch (error) {
setFailed(error as string | Error);
Expand Down
2 changes: 1 addition & 1 deletion src/purge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const purge = async (
accessKey: string
): Promise<Response> => {
const response = await fetch(
`https://bunnycdn.com/api/pullzone/${pullZoneId}/purgeCache`,
`https://api.bunny.net/pullzone/${pullZoneId}/purgeCache`,
{
method: "POST",
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/test/purge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("when calling purge function", () => {
it("should call purge API", async () => {
await purge("zoneId", "zoneKey");
expect(fetchMock).toHaveBeenCalledWith(
"https://bunnycdn.com/api/pullzone/zoneId/purgeCache",
"https://api.bunny.net/pullzone/zoneId/purgeCache",
expect.anything()
);
expect(fetchMock).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 3af7d3c

Please sign in to comment.