Compare commits
102 Commits
v3.4
...
maximo/test-351
| Author | SHA1 | Date | |
|---|---|---|---|
| 9fde81df51 | |||
| 4ff07f4310 | |||
| 4fb15f8b7a | |||
| e8cd5f0968 | |||
| e209094e62 | |||
| 181b9fb5d6 | |||
| aac328d155 | |||
| fc89533f1e | |||
| e819570b2d | |||
| 923db6f87f | |||
| d5031c3dbe | |||
| 17da943335 | |||
| 3aee84cd6d | |||
| 9d9bee8bfd | |||
| ee57f258dc | |||
| 9fed19aa4e | |||
| 3c6e4da7b3 | |||
| 1c0eef186f | |||
| b19342b08c | |||
| d44c80928a | |||
| cada7a6312 | |||
| 1e92eee7d2 | |||
| e7e5400334 | |||
| d58f116d72 | |||
| 64b6339110 | |||
| ac2fd0ec8f | |||
| 0140ffbc93 | |||
| cc4ede3f06 | |||
| 9bf87caf2b | |||
| 81f8814855 | |||
| 6c6d3321ef | |||
| bc61e66e47 | |||
| 0e2b86ba21 | |||
| 59c0462940 | |||
| 4c3f0c27ea | |||
| 4d045615a9 | |||
| a7a2388d7b | |||
| 95555f6ed0 | |||
| 2171bbdd69 | |||
| 4f4ff59d17 | |||
| 122ee5cf5b | |||
| 44d79edf44 | |||
| b2be7abbfc | |||
| b7158dc9a4 | |||
| 43767e73de | |||
| 10d5b9c1c1 | |||
| c01035706f | |||
| fa96c39bd4 | |||
| 78dad1df07 | |||
| 3ec7f8943e | |||
| cd8a317efb | |||
| 6aa2e8946a | |||
| de0526e09b | |||
| 84316ca95c | |||
| 134b5c2a32 | |||
| 47d51f25c1 | |||
| 93fff4f656 | |||
| 66334dff0a | |||
| 9966912c1b | |||
| 7b9aec5185 | |||
| c0e117f512 | |||
| bcff5386ec | |||
| c15498da36 | |||
| 8bc5c5f050 | |||
| ac21b71592 | |||
| f111269956 | |||
| 570d521df6 | |||
| 174337b3b4 | |||
| a1467a0c8f | |||
| 3ea6e3f132 | |||
| ea11499226 | |||
| 8f2f89521c | |||
| 66efca2cbb | |||
| aa5d18dd1e | |||
| b84268f0e0 | |||
| d1b97ebf4d | |||
| baf8bc61f1 | |||
| 8edd152f63 | |||
| 2d275a8f2d | |||
| 8ef515f899 | |||
| 9b27cf271c | |||
| 405a82610b | |||
| 0545ad285a | |||
| ea5754c9ad | |||
| 983b6349c2 | |||
| b05934f581 | |||
| 31a6263ef3 | |||
| 88906781f0 | |||
| ebef541795 | |||
| 9d4ca0f255 | |||
| 1be73b90f6 | |||
| 180648017b | |||
| 9003b06015 | |||
| fd98a7c990 | |||
| 4bf3047bb8 | |||
| f2c22accd3 | |||
| 0c36639f72 | |||
| d5a1abb013 | |||
| c214b69bae | |||
| bac2829d42 | |||
| 78c994fb95 | |||
| e3434a7e98 |
@@ -1,7 +1,7 @@
|
||||
# Changesets
|
||||
|
||||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
||||
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
||||
with multi-package repos, or single-package repos to help you version and deploy your code. You can
|
||||
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
||||
|
||||
We have a quick list of common questions to get you started engaging with this project in
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"wrangler-action": patch
|
||||
---
|
||||
|
||||
Handle failures in createGitHubDeployment and createGitHubJobSummary
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"wrangler-action": minor
|
||||
---
|
||||
|
||||
Use wrangler outputs for version upload and wrangler deploy
|
||||
@@ -14,7 +14,8 @@ jobs:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "latest"
|
||||
# Pinned due to compatibility issues on 23.2.0
|
||||
node-version: "22"
|
||||
cache: "npm"
|
||||
|
||||
- name: Install modules and build
|
||||
@@ -29,7 +30,7 @@ jobs:
|
||||
- name: Only build app
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/base"
|
||||
workingDirectory: "./src/test/fixtures/only-build"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: deploy --dry-run
|
||||
@@ -38,20 +39,20 @@ jobs:
|
||||
uses: ./
|
||||
with:
|
||||
quiet: true
|
||||
workingDirectory: "./test/base"
|
||||
workingDirectory: "./src/test/fixtures/build-quiet"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: deploy --dry-run
|
||||
|
||||
# START Setup and teardown of Worker Environment Tests
|
||||
- name: Environment support
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/environment"
|
||||
workingDirectory: "./src/test/fixtures/environment"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
environment: dev
|
||||
preCommands: npx wrangler deploy --env dev # https://github.com/cloudflare/wrangler-action/issues/162
|
||||
postCommands: npx wrangler delete --name wrangler-action-dev-environment-test --force
|
||||
secrets: |
|
||||
SECRET1
|
||||
SECRET2
|
||||
@@ -59,21 +60,12 @@ jobs:
|
||||
SECRET1: ${{ secrets.SECRET1 }}
|
||||
SECRET2: ${{ secrets.SECRET2 }}
|
||||
|
||||
- name: Clean up Deployed Environment Worker
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/base"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: delete --name wrangler-action-dev-environment-test --force
|
||||
|
||||
# END Setup and teardown of Worker Environment Tests
|
||||
# START Setup and teardown of Workers w/ Secrets Tests
|
||||
- name: Deploy app secrets w/ hardcoded Wrangler v2
|
||||
uses: ./
|
||||
with:
|
||||
wranglerVersion: "2.20.0"
|
||||
workingDirectory: "./test/base"
|
||||
workingDirectory: "./src/test/fixtures/secrets-v2"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
secrets: |
|
||||
@@ -84,13 +76,13 @@ jobs:
|
||||
SECRET2: ${{ secrets.SECRET2 }}
|
||||
|
||||
- name: Health Check Deployed Worker
|
||||
run: node .github/workflows/workerHealthCheck.cjs
|
||||
run: node .github/workflows/workerHealthCheck.cjs wrangler-action-test-secrets-v2
|
||||
shell: bash
|
||||
|
||||
- name: Deploy app secrets w/ default version
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/base"
|
||||
workingDirectory: "./src/test/fixtures/secrets-default"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
secrets: |
|
||||
@@ -101,22 +93,23 @@ jobs:
|
||||
SECRET2: ${{ secrets.SECRET2 }}
|
||||
|
||||
- name: Health Check Deployed Worker
|
||||
run: node .github/workflows/workerHealthCheck.cjs
|
||||
run: node .github/workflows/workerHealthCheck.cjs wrangler-action-test-secrets-default
|
||||
shell: bash
|
||||
|
||||
- name: Clean Up Deployed Workers
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/base"
|
||||
workingDirectory: "./src/test/fixtures/secrets-default"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: delete --name wrangler-action-test --force
|
||||
command: delete --name wrangler-action-test-secrets-v2 --force
|
||||
postCommands: npx wrangler delete --name wrangler-action-test-secrets-default --force
|
||||
# END Setup and teardown of Workers w/ Secrets Tests
|
||||
|
||||
- name: Support packageManager variable
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/empty"
|
||||
workingDirectory: "./src/test/fixtures/specify-package-manager"
|
||||
packageManager: "npm"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
@@ -125,7 +118,7 @@ jobs:
|
||||
- name: Support unspecified packageManager with no lockfile
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/empty"
|
||||
workingDirectory: "./src/test/fixtures/unspecified-package-manager"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: deploy --dry-run
|
||||
@@ -133,7 +126,7 @@ jobs:
|
||||
- name: Support npm package manager
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/npm"
|
||||
workingDirectory: "./src/test/fixtures/npm"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: deploy --dry-run
|
||||
@@ -144,7 +137,7 @@ jobs:
|
||||
- name: Support yarn package manager
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/yarn"
|
||||
workingDirectory: "./src/test/fixtures/yarn"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: deploy --dry-run
|
||||
@@ -155,7 +148,18 @@ jobs:
|
||||
- name: Support pnpm package manager
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./test/pnpm"
|
||||
workingDirectory: "./src/test/fixtures/pnpm"
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: deploy --dry-run
|
||||
|
||||
- name: Change directory to pre-installed-wrangler and install dependencies
|
||||
run: |
|
||||
cd ./src/test/fixtures/pre-installed-wrangler
|
||||
npm install
|
||||
|
||||
- name: Support pre-installed wrangler
|
||||
uses: ./
|
||||
with:
|
||||
workingDirectory: "./src/test/fixtures/pre-installed-wrangler"
|
||||
command: action-test
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
name: Issue
|
||||
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- opened
|
||||
- transferred
|
||||
|
||||
jobs:
|
||||
add-to-project:
|
||||
name: Add issue to workers-sdk GH project
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/add-to-project@v0.5.0
|
||||
with:
|
||||
project-url: https://github.com/orgs/cloudflare/projects/1
|
||||
github-token: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
@@ -1,10 +0,0 @@
|
||||
name: Pull request
|
||||
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
add-to-project:
|
||||
name: Add PR to workers-sdk GH project
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: curl -X POST https://devprod-status-bot.devprod.workers.dev/pr-project/wrangler-action/${{ github.event.number }}
|
||||
@@ -27,7 +27,8 @@ jobs:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "latest"
|
||||
# Pinned due to compatibility issues on 23.2.0
|
||||
node-version: "22"
|
||||
cache: "npm"
|
||||
|
||||
- name: Install modules
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
on:
|
||||
pull_request: {}
|
||||
workflow_dispatch: {}
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
name: Semgrep config
|
||||
jobs:
|
||||
semgrep:
|
||||
name: semgrep/ci
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
|
||||
SEMGREP_URL: https://cloudflare.semgrep.dev
|
||||
SEMGREP_APP_URL: https://cloudflare.semgrep.dev
|
||||
SEMGREP_VERSION_CHECK_URL: https://cloudflare.semgrep.dev/api/check-version
|
||||
container:
|
||||
image: semgrep/semgrep
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: semgrep ci
|
||||
@@ -1,8 +1,7 @@
|
||||
const { execSync } = require("child_process");
|
||||
|
||||
function workerHealthCheck() {
|
||||
const url =
|
||||
"https://wrangler-action-test.devprod-testing7928.workers.dev/secret-health-check";
|
||||
function workerHealthCheck(workerName) {
|
||||
const url = `https://${workerName}.devprod-testing7928.workers.dev/secret-health-check`;
|
||||
|
||||
const buffer = execSync(`curl ${url}`);
|
||||
|
||||
@@ -17,4 +16,13 @@ function workerHealthCheck() {
|
||||
return response;
|
||||
}
|
||||
|
||||
workerHealthCheck();
|
||||
const args = Array.from(process.argv);
|
||||
const workerName = args.pop();
|
||||
|
||||
if (!workerName) {
|
||||
throw new Error(
|
||||
"Please provide the worker name as an argument when calling this program.",
|
||||
);
|
||||
}
|
||||
|
||||
workerHealthCheck(workerName);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
dist
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
|
||||
@@ -1,5 +1,91 @@
|
||||
# Changelog
|
||||
|
||||
## 3.13.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#345](https://github.com/cloudflare/wrangler-action/pull/345) [`e819570`](https://github.com/cloudflare/wrangler-action/commit/e819570b2d0a69816a1c2e9d2f2954e278748d80) Thanks [@Maximo-Guk](https://github.com/Maximo-Guk)! - fix: Pages GitHub Deployment not triggering
|
||||
|
||||
## 3.13.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#325](https://github.com/cloudflare/wrangler-action/pull/325) [`cada7a6`](https://github.com/cloudflare/wrangler-action/commit/cada7a63124ded3471bef7e8001b76356b838e40) Thanks [@Maximo-Guk](https://github.com/Maximo-Guk)! - Add GitHub deployments and job summaries for parity with pages-action
|
||||
|
||||
- [#334](https://github.com/cloudflare/wrangler-action/pull/334) [`9fed19a`](https://github.com/cloudflare/wrangler-action/commit/9fed19aa4ed79946f009e8aad7437a922e62d523) Thanks [@Maximo-Guk](https://github.com/Maximo-Guk)! - Bump default wrangler version to 3.90.0
|
||||
|
||||
## 3.12.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#319](https://github.com/cloudflare/wrangler-action/pull/319) [`59c04629408d58978884fadd18755f1a15f96157`](https://github.com/cloudflare/wrangler-action/commit/59c04629408d58978884fadd18755f1a15f96157) Thanks [@Maximo-Guk](https://github.com/Maximo-Guk)! - Fixes #317: Generate a new output directory with a randomUUID in the tmpDir, so that when the action is executed multiple times, we use the artifacts from that run, opposed to the artifacts from a previous run.
|
||||
|
||||
## 3.12.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#312](https://github.com/cloudflare/wrangler-action/pull/312) [`122ee5cf5b66847e0b6cfa67ecd9e03e38a67a42`](https://github.com/cloudflare/wrangler-action/commit/122ee5cf5b66847e0b6cfa67ecd9e03e38a67a42) Thanks [@Maximo-Guk](https://github.com/Maximo-Guk)! - This reapplies [303](https://github.com/cloudflare/wrangler-action/pull/303) add parity with pages-action for pages deploy outputs. Thanks @courtney-sims! - Support pages-deployment-id, pages-environment, pages-deployment-alias-url and deployment-url outputs for Pages deploys when wrangler version is >=3.81.0. deployment-alias-url was also deprecated in favour of pages-deployment-alias.
|
||||
|
||||
## 3.11.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#309](https://github.com/cloudflare/wrangler-action/pull/309) [`10d5b9c1c1826adaec0a9ee49fdf5b91113508ef`](https://github.com/cloudflare/wrangler-action/commit/10d5b9c1c1826adaec0a9ee49fdf5b91113508ef) Thanks [@Maximo-Guk](https://github.com/Maximo-Guk)! - Revert "Add parity with pages-action for pages deploy outputs"
|
||||
|
||||
## 3.10.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#303](https://github.com/cloudflare/wrangler-action/pull/303) [`3ec7f8943ef83351f743cfaa8763a9056ef70993`](https://github.com/cloudflare/wrangler-action/commit/3ec7f8943ef83351f743cfaa8763a9056ef70993) Thanks [@courtney-sims](https://github.com/courtney-sims)! - Support id, environment, url, and alias outputs for Pages deploys.
|
||||
|
||||
## 3.9.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#298](https://github.com/cloudflare/wrangler-action/pull/298) [`134b5c2a3252d66b8c4d1cddd0b9baaeed6a4daa`](https://github.com/cloudflare/wrangler-action/commit/134b5c2a3252d66b8c4d1cddd0b9baaeed6a4daa) Thanks [@Maximo-Guk](https://github.com/Maximo-Guk)! - Update wrangler version from 3.13.2 to 3.78.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#278](https://github.com/cloudflare/wrangler-action/pull/278) [`47d51f25c113ee9205110728599b43ed6a1e273b`](https://github.com/cloudflare/wrangler-action/commit/47d51f25c113ee9205110728599b43ed6a1e273b) Thanks [@acusti](https://github.com/acusti)! - fix: Detect existing wrangler install even when wrangler version output is multiline
|
||||
|
||||
## 3.8.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#291](https://github.com/cloudflare/wrangler-action/pull/291) [`a1467a0c8f2a058f8d43a4d0c40a55176ed5efe6`](https://github.com/cloudflare/wrangler-action/commit/a1467a0c8f2a058f8d43a4d0c40a55176ed5efe6) Thanks [@Ambroos](https://github.com/Ambroos)! - Adds `deployment-alias-url` output for Pages deployment aliases (since Wrangler v3.78.0): https://github.com/cloudflare/workers-sdk/pull/6643
|
||||
|
||||
## 3.7.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#271](https://github.com/cloudflare/wrangler-action/pull/271) [`66efca2cbb82a5a49df6af2e14c4b58d53b0e266`](https://github.com/cloudflare/wrangler-action/commit/66efca2cbb82a5a49df6af2e14c4b58d53b0e266) Thanks [@Maximo-Guk](https://github.com/Maximo-Guk)! - This unreverts #235 ensuring wrangler-action will re-use existing wrangler installations, thanks @AdiRishi! and ensures we don't automatically install wrangler when checking if it present
|
||||
|
||||
## 3.6.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#265](https://github.com/cloudflare/wrangler-action/pull/265) [`2d275a8f2d279dc91912c1ff8023af109ef3280c`](https://github.com/cloudflare/wrangler-action/commit/2d275a8f2d279dc91912c1ff8023af109ef3280c) Thanks [@Maximo-Guk](https://github.com/Maximo-Guk)! - Reverts #235 which may have caused the latest version of wrangler to be installed, if no wrangler version was found
|
||||
|
||||
## 3.6.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#235](https://github.com/cloudflare/wrangler-action/pull/235) [`0545ad285acaff2b92053d636ee17fb303b4c5f5`](https://github.com/cloudflare/wrangler-action/commit/0545ad285acaff2b92053d636ee17fb303b4c5f5) Thanks [@AdiRishi](https://github.com/AdiRishi)! - wrangler-action will now re-use existing wrangler installations when available
|
||||
|
||||
## 3.5.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#255](https://github.com/cloudflare/wrangler-action/pull/255) [`31a6263ef3ec73ff2d03cb4c0260379f96f7598c`](https://github.com/cloudflare/wrangler-action/commit/31a6263ef3ec73ff2d03cb4c0260379f96f7598c) Thanks [@matthewdavidrodgers](https://github.com/matthewdavidrodgers)! - Stop racing secret uploads
|
||||
|
||||
For up to date versions of wrangler, secrets are uploaded via the 'secret:bulk' command, which batches updates in a single API call.
|
||||
|
||||
For versions of wrangler without that capability, the action falls back to the single 'secret put' command for each secret. It races all these with a Promise.all()
|
||||
|
||||
Unfortunately, the single secret API cannot handle concurrency - at best, these calls have to wait on one another, holding requests open all the while. Often it times out and errors.
|
||||
|
||||
This fixes the legacy secret upload errors by making these calls serially instead of concurrently.
|
||||
|
||||
## 3.4.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
* @cloudflare/wrangler
|
||||
* @cloudflare/wrangler @cloudflare/banda-team
|
||||
|
||||
CHANGELOG.md @cloudflare/wrangler-admins
|
||||
CHANGELOG.md @cloudflare/wrangler-admins @cloudflare/banda-team
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# Contributing Guide
|
||||
|
||||
## Releases
|
||||
|
||||
### Changesets
|
||||
|
||||
Every non-trivial change to the project - those that should appear in the changelog - must be captured in a "changeset". We use the changesets tool for creating changesets, publishing versions and updating the changelog.
|
||||
|
||||
Create a changeset for the current change.
|
||||
|
||||
> npx changeset
|
||||
> Select which workspaces are affected by the change and whether the version requires a major, minor or patch release.
|
||||
> Update the generated changeset with a description of the change.
|
||||
> Include the generate changeset in the current commit.
|
||||
> git add ./changeset/\*.md
|
||||
|
||||
### Version Packages PRs
|
||||
|
||||
Once you merge your PR, a new Version Packages PR will be opened in the wrangler-action repo. Once that PR is merged, your change will be released. Example: https://github.com/cloudflare/wrangler-action/pull/305
|
||||
|
||||
Note: Version Packages PRs are only generated if there's been at least one PR merged with a changeset.
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Deploy
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
workingDirectory: "subfoldername"
|
||||
```
|
||||
|
||||
[Worker secrets](https://developers.cloudflare.com/workers/tooling/wrangler/secrets/) can optionally be passed in via `secrets` as a string of names separated by newlines. Each secret name must match the name of an environment variable specified in the `env` field. This creates or replaces the value for the Worker secret using the `wrangler secret put` command.
|
||||
[Worker secrets](https://developers.cloudflare.com/workers/tooling/wrangler/secrets/) can optionally be passed in via `secrets` as a string of names separated by newlines. Each secret name must match the name of an environment variable specified in the `env` field. This creates or replaces the value for the Worker secret using the `wrangler secret put` command. It's also possible to specify worker environment using environment parameter.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
@@ -85,6 +85,7 @@ jobs:
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
environment: production
|
||||
secrets: |
|
||||
SECRET1
|
||||
SECRET2
|
||||
@@ -121,6 +122,20 @@ jobs:
|
||||
command: whoami
|
||||
```
|
||||
|
||||
You can also add a command that spans multiple lines:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
command: |
|
||||
pages project list
|
||||
pages deploy .vercel/output/static --project-name=demo-actions --branch=test
|
||||
```
|
||||
|
||||
## Use cases
|
||||
|
||||
### Deploy when commits are merged to main
|
||||
@@ -138,7 +153,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Deploy
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
@@ -158,14 +173,19 @@ jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
permissions:
|
||||
contents: read
|
||||
deployments: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Deploy
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: pages deploy --project-name=example
|
||||
command: pages deploy YOUR_DIST_FOLDER --project-name=example
|
||||
# Optional: Enable this if you want to have GitHub Deployments triggered
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### Deploying on a schedule
|
||||
@@ -182,7 +202,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Deploy app
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
@@ -208,7 +228,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Deploy app
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
@@ -218,8 +238,43 @@ jobs:
|
||||
|
||||
For more advanced usage or to programmatically trigger the workflow from scripts, refer to [the GitHub documentation](https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event) for making API calls.
|
||||
|
||||
### Upload a Worker Version
|
||||
|
||||
To create a new version of your Worker that is not deployed immediately, use the `wrangler versions upload` command. Worker versions created in this way can then be deployed all at once at a later time or gradually deployed using the `wrangler versions deploy` command or via the Cloudflare dashboard under the Deployments tab. Wrangler v3.40.0 or above is required to use this feature.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
upload:
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Upload Worker Version
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: versions upload
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Setting A Worker Secret for A Specific Environment
|
||||
|
||||
There is an environment parameter that can be set within the workflow to enable this. Example:
|
||||
|
||||
```yaml
|
||||
- uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
command: deploy --env production
|
||||
secrets: |
|
||||
SUPER_SECRET
|
||||
environment: production
|
||||
env:
|
||||
SUPER_SECRET: ${{ secrets.SUPER_SECRET }}
|
||||
```
|
||||
|
||||
### Using Wrangler Command Output in Subsequent Steps
|
||||
|
||||
More advanced workflows may need to parse the resulting output of Wrangler commands. To do this, you can use the `command-output` output variable in subsequent steps. For example, if you want to print the output of the Wrangler command, you can do the following:
|
||||
@@ -243,7 +298,7 @@ Now when you run your workflow, you will see the full output of the Wrangler com
|
||||
|
||||
> Note: the `command-stderr` output variable is also available if you need to parse the standard error output of the Wrangler command.
|
||||
|
||||
### Using the `deployment-url` Output Variable
|
||||
### Using the `deployment-url` and `pages-deployment-alias-url` Output Variables
|
||||
|
||||
If you are executing a Wrangler command that results in either a Workers or Pages deployment, you can utilize the `deployment-url` output variable to get the URL of the deployment. For example, if you want to print the deployment URL after deploying your application, you can do the following:
|
||||
|
||||
@@ -268,6 +323,39 @@ The resulting output will look something like this:
|
||||
https://<your_pages_site>.pages.dev
|
||||
```
|
||||
|
||||
Pages deployments will also provide their alias URL (since Wrangler v3.78.0). You can use the `pages-deployment-alias-url` output variable to get the URL of the deployment alias. This is useful for, for example, branch aliases for preview deployments.
|
||||
|
||||
If the sample action above was used to deploy a branch other than main, you could use the following to get the branch URL:
|
||||
|
||||
```yaml
|
||||
- name: print pages-deployment-alias-url
|
||||
env:
|
||||
DEPLOYMENT_ALIAS_URL: ${{ steps.deploy.outputs.pages-deployment-alias-url }}
|
||||
run: echo $DEPLOYMENT_ALIAS_URL
|
||||
```
|
||||
|
||||
Resulting in:
|
||||
|
||||
```text
|
||||
https://new-feature.<your_pages_site>.pages.dev
|
||||
```
|
||||
|
||||
### Using a different package manager
|
||||
|
||||
By default, this action will detect which package manager to use, based on the presence of a `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, or `bun.lockb`/`bun.lock` file.
|
||||
|
||||
If you need to use a specific package manager for your application, you can set the `packageManager` input to `npm`, `yarn`, `pnpm`, or `bun`. You don't need to set this option unless you want to override the default behavior.
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
deploy:
|
||||
steps:
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
packageManager: pnpm
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "I just started using Workers/Wrangler and I don't know what this is!"
|
||||
@@ -286,7 +374,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Deploy app
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
|
||||
@@ -44,6 +44,9 @@ inputs:
|
||||
packageManager:
|
||||
description: "The package manager you'd like to use to install and run wrangler. If not specified, the preferred package manager will be inferred based on the presence of a lockfile or fallback to using npm if no lockfile is found. Valid values are `npm` | `pnpm` | `yarn` | `bun`."
|
||||
required: false
|
||||
gitHubToken:
|
||||
description: "GitHub Token"
|
||||
required: false
|
||||
outputs:
|
||||
command-output:
|
||||
description: "The output of the Wrangler command (comes from stdout)"
|
||||
@@ -51,3 +54,9 @@ outputs:
|
||||
description: "The error output of the Wrangler command (comes from stderr)"
|
||||
deployment-url:
|
||||
description: "If the command was a Workers or Pages deployment, this will be the URL of the deployment"
|
||||
pages-deployment-alias-url:
|
||||
description: "If the command was a Pages deployment, this will be the URL of the deployment alias (if it exists) - needs wrangler >= 3.78.0"
|
||||
pages-deployment-id:
|
||||
description: "If the command was a Pages deployment, this will be the ID of the deployment - needs wrangler >= 3.81.0"
|
||||
pages-environment:
|
||||
description: "If the command was a Pages deployment, this will be the environment of the deployment - needs wrangler >= 3.81.0"
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
import { WranglerActionConfig } from "./wranglerAction";
|
||||
export declare function handleCommandOutputParsing(config: WranglerActionConfig, command: string, stdOut: string): Promise<void>;
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import { exec as _childProcessExec } from "node:child_process";
|
||||
export { exec } from "@actions/exec";
|
||||
declare const childProcessExec: typeof _childProcessExec.__promisify__;
|
||||
export declare function execShell(command: string, { silent, ...options }?: Parameters<typeof childProcessExec>[1] & {
|
||||
silent?: boolean;
|
||||
}): Promise<number | null>;
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Vendored
+37332
File diff suppressed because one or more lines are too long
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
export interface PackageManager {
|
||||
install: string;
|
||||
exec: string;
|
||||
execNoInstall: string;
|
||||
}
|
||||
export declare function getPackageManager(name: string, { workingDirectory }?: {
|
||||
workingDirectory?: string;
|
||||
}): {
|
||||
readonly install: "npm i";
|
||||
readonly exec: "npx";
|
||||
readonly execNoInstall: "npx --no-install";
|
||||
} | {
|
||||
readonly install: "yarn add";
|
||||
readonly exec: "yarn";
|
||||
readonly execNoInstall: "yarn";
|
||||
} | {
|
||||
readonly install: "pnpm add";
|
||||
readonly exec: "pnpm exec";
|
||||
readonly execNoInstall: "pnpm exec";
|
||||
} | {
|
||||
readonly install: "bun i";
|
||||
readonly exec: "bunx";
|
||||
readonly execNoInstall: "bun run";
|
||||
};
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
import { getOctokit } from "@actions/github";
|
||||
import { OutputEntryPagesDeployment } from "../wranglerArtifactManager";
|
||||
import { WranglerActionConfig } from "../wranglerAction";
|
||||
type Octokit = ReturnType<typeof getOctokit>;
|
||||
export declare function createGitHubDeployment({ config, octokit, productionBranch, environment, deploymentId, projectName, deploymentUrl, }: {
|
||||
config: WranglerActionConfig;
|
||||
octokit: Octokit;
|
||||
productionBranch: string;
|
||||
environment: string;
|
||||
deploymentId: string | null;
|
||||
projectName: string;
|
||||
deploymentUrl?: string;
|
||||
}): Promise<void>;
|
||||
export declare function createJobSummary({ commitHash, deploymentUrl, aliasUrl, }: {
|
||||
commitHash: string;
|
||||
deploymentUrl?: string;
|
||||
aliasUrl?: string;
|
||||
}): Promise<void>;
|
||||
/**
|
||||
* Create github deployment, if GITHUB_TOKEN is present in config
|
||||
*/
|
||||
export declare function createGitHubDeploymentAndJobSummary(config: WranglerActionConfig, pagesArtifactFields: OutputEntryPagesDeployment): Promise<void>;
|
||||
export {};
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
declare const _default: {
|
||||
fetch(request: Request, env: Env): Response;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
declare const _default: {
|
||||
fetch(request: Request, env: Env): Response;
|
||||
};
|
||||
export default _default;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
declare const _default: {
|
||||
fetch(request: Request, env: Env): Response;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
declare const _default: {
|
||||
fetch(request: Request, env: Env): Response;
|
||||
};
|
||||
export default _default;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
declare const _default: {
|
||||
fetch(request: Request, env: Env): Response;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
declare const _default: {
|
||||
fetch(request: Request, env: Env): Response;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,8 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
declare const _default: {
|
||||
fetch(request: Request, env: Env): Response;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,8 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
declare const _default: {
|
||||
fetch(request: Request, env: Env): Response;
|
||||
};
|
||||
export default _default;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
declare const _default: {
|
||||
fetch(request: Request, env: Env): Response;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,2 @@
|
||||
declare const _default: {};
|
||||
export default _default;
|
||||
@@ -0,0 +1,2 @@
|
||||
declare const _default: {};
|
||||
export default _default;
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
declare const _default: {
|
||||
fetch(request: Request, env: Env): Response;
|
||||
};
|
||||
export default _default;
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
export declare function mockGithubDeployments({ githubUser, githubRepoName, }: {
|
||||
githubUser: string;
|
||||
githubRepoName: string;
|
||||
}): {
|
||||
handlers: import("msw").HttpHandler[];
|
||||
};
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import { WranglerActionConfig } from "../wranglerAction";
|
||||
export declare function getTestConfig({ config, }?: {
|
||||
config?: Partial<WranglerActionConfig>;
|
||||
}): WranglerActionConfig;
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import { WranglerActionConfig } from "./wranglerAction";
|
||||
/**
|
||||
* A helper function to compare two semver versions. If the second arg is greater than the first arg, it returns true.
|
||||
*/
|
||||
export declare function semverCompare(version1: string, version2: string): boolean;
|
||||
export declare function checkWorkingDirectory(workingDirectory?: string): string;
|
||||
export declare function info(config: WranglerActionConfig, message: string, bypass?: boolean): void;
|
||||
export declare function warn(config: WranglerActionConfig, message: string, bypass?: boolean): void;
|
||||
export declare function error(config: WranglerActionConfig, message: string, bypass?: boolean): void;
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
import { z } from "zod";
|
||||
import { PackageManager } from "./packageManagers";
|
||||
import { info } from "./utils";
|
||||
export type WranglerActionConfig = z.infer<typeof wranglerActionConfig>;
|
||||
export declare const wranglerActionConfig: z.ZodObject<{
|
||||
WRANGLER_VERSION: z.ZodString;
|
||||
didUserProvideWranglerVersion: z.ZodBoolean;
|
||||
secrets: z.ZodArray<z.ZodString, "many">;
|
||||
workingDirectory: z.ZodString;
|
||||
CLOUDFLARE_API_TOKEN: z.ZodString;
|
||||
CLOUDFLARE_ACCOUNT_ID: z.ZodString;
|
||||
ENVIRONMENT: z.ZodString;
|
||||
VARS: z.ZodArray<z.ZodString, "many">;
|
||||
COMMANDS: z.ZodArray<z.ZodString, "many">;
|
||||
QUIET_MODE: z.ZodBoolean;
|
||||
PACKAGE_MANAGER: z.ZodString;
|
||||
WRANGLER_OUTPUT_DIR: z.ZodString;
|
||||
GITHUB_TOKEN: z.ZodString;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
WRANGLER_VERSION: string;
|
||||
didUserProvideWranglerVersion: boolean;
|
||||
secrets: string[];
|
||||
workingDirectory: string;
|
||||
CLOUDFLARE_API_TOKEN: string;
|
||||
CLOUDFLARE_ACCOUNT_ID: string;
|
||||
ENVIRONMENT: string;
|
||||
VARS: string[];
|
||||
COMMANDS: string[];
|
||||
QUIET_MODE: boolean;
|
||||
PACKAGE_MANAGER: string;
|
||||
WRANGLER_OUTPUT_DIR: string;
|
||||
GITHUB_TOKEN: string;
|
||||
}, {
|
||||
WRANGLER_VERSION: string;
|
||||
didUserProvideWranglerVersion: boolean;
|
||||
secrets: string[];
|
||||
workingDirectory: string;
|
||||
CLOUDFLARE_API_TOKEN: string;
|
||||
CLOUDFLARE_ACCOUNT_ID: string;
|
||||
ENVIRONMENT: string;
|
||||
VARS: string[];
|
||||
COMMANDS: string[];
|
||||
QUIET_MODE: boolean;
|
||||
PACKAGE_MANAGER: string;
|
||||
WRANGLER_OUTPUT_DIR: string;
|
||||
GITHUB_TOKEN: string;
|
||||
}>;
|
||||
declare function main(config: WranglerActionConfig, packageManager: PackageManager): Promise<void>;
|
||||
declare function installWrangler(config: WranglerActionConfig, packageManager: PackageManager): Promise<void>;
|
||||
declare function authenticationSetup(config: WranglerActionConfig): void;
|
||||
declare function execCommands(config: WranglerActionConfig, packageManager: PackageManager, commands: string[], cmdType: string): Promise<void>;
|
||||
declare function uploadSecrets(config: WranglerActionConfig, packageManager: PackageManager): Promise<void>;
|
||||
declare function wranglerCommands(config: WranglerActionConfig, packageManager: PackageManager): Promise<void>;
|
||||
export { authenticationSetup, execCommands, info, installWrangler, main, uploadSecrets, wranglerCommands, };
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Vendored
+200
@@ -0,0 +1,200 @@
|
||||
import { z } from "zod";
|
||||
export type OutputEntryPagesDeployment = z.infer<typeof OutputEntryPagesDeployment>;
|
||||
declare const OutputEntryPagesDeployment: z.ZodObject<z.objectUtil.extendShape<{
|
||||
version: z.ZodLiteral<1>;
|
||||
type: z.ZodString;
|
||||
}, {
|
||||
type: z.ZodLiteral<"pages-deploy-detailed">;
|
||||
pages_project: z.ZodNullable<z.ZodString>;
|
||||
deployment_id: z.ZodNullable<z.ZodString>;
|
||||
url: z.ZodOptional<z.ZodString>;
|
||||
alias: z.ZodOptional<z.ZodString>;
|
||||
environment: z.ZodEnum<["production", "preview"]>;
|
||||
production_branch: z.ZodOptional<z.ZodString>;
|
||||
deployment_trigger: z.ZodOptional<z.ZodObject<{
|
||||
metadata: z.ZodObject<{
|
||||
/** Commit hash of the deployment trigger metadata for the pages project */
|
||||
commit_hash: z.ZodString;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
commit_hash: string;
|
||||
}, {
|
||||
commit_hash: string;
|
||||
}>;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
metadata: {
|
||||
commit_hash: string;
|
||||
};
|
||||
}, {
|
||||
metadata: {
|
||||
commit_hash: string;
|
||||
};
|
||||
}>>;
|
||||
}>, "strip", z.ZodTypeAny, {
|
||||
type: "pages-deploy-detailed";
|
||||
environment: "production" | "preview";
|
||||
version: 1;
|
||||
pages_project: string | null;
|
||||
deployment_id: string | null;
|
||||
url?: string | undefined;
|
||||
alias?: string | undefined;
|
||||
production_branch?: string | undefined;
|
||||
deployment_trigger?: {
|
||||
metadata: {
|
||||
commit_hash: string;
|
||||
};
|
||||
} | undefined;
|
||||
}, {
|
||||
type: "pages-deploy-detailed";
|
||||
environment: "production" | "preview";
|
||||
version: 1;
|
||||
pages_project: string | null;
|
||||
deployment_id: string | null;
|
||||
url?: string | undefined;
|
||||
alias?: string | undefined;
|
||||
production_branch?: string | undefined;
|
||||
deployment_trigger?: {
|
||||
metadata: {
|
||||
commit_hash: string;
|
||||
};
|
||||
} | undefined;
|
||||
}>;
|
||||
export type OutputEntryDeployment = z.infer<typeof OutputEntryDeployment>;
|
||||
declare const OutputEntryDeployment: z.ZodObject<z.objectUtil.extendShape<{
|
||||
version: z.ZodLiteral<1>;
|
||||
type: z.ZodString;
|
||||
}, {
|
||||
type: z.ZodLiteral<"deploy">;
|
||||
/** A list of URLs that represent the HTTP triggers associated with this deployment */
|
||||
/** basically, for wrangler-action purposes this is the deployment urls */
|
||||
targets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
||||
}>, "strip", z.ZodTypeAny, {
|
||||
type: "deploy";
|
||||
version: 1;
|
||||
targets?: string[] | undefined;
|
||||
}, {
|
||||
type: "deploy";
|
||||
version: 1;
|
||||
targets?: string[] | undefined;
|
||||
}>;
|
||||
export type OutputEntryVersionUpload = z.infer<typeof OutputEntryVersionUpload>;
|
||||
declare const OutputEntryVersionUpload: z.ZodObject<z.objectUtil.extendShape<{
|
||||
version: z.ZodLiteral<1>;
|
||||
type: z.ZodString;
|
||||
}, {
|
||||
type: z.ZodLiteral<"version-upload">;
|
||||
/** The preview URL associated with this version upload */
|
||||
preview_url: z.ZodOptional<z.ZodString>;
|
||||
}>, "strip", z.ZodTypeAny, {
|
||||
type: "version-upload";
|
||||
version: 1;
|
||||
preview_url?: string | undefined;
|
||||
}, {
|
||||
type: "version-upload";
|
||||
version: 1;
|
||||
preview_url?: string | undefined;
|
||||
}>;
|
||||
export type SupportedOutputEntry = z.infer<typeof SupportedOutputEntry>;
|
||||
declare const SupportedOutputEntry: z.ZodDiscriminatedUnion<"type", [z.ZodObject<z.objectUtil.extendShape<{
|
||||
version: z.ZodLiteral<1>;
|
||||
type: z.ZodString;
|
||||
}, {
|
||||
type: z.ZodLiteral<"pages-deploy-detailed">;
|
||||
pages_project: z.ZodNullable<z.ZodString>;
|
||||
deployment_id: z.ZodNullable<z.ZodString>;
|
||||
url: z.ZodOptional<z.ZodString>;
|
||||
alias: z.ZodOptional<z.ZodString>;
|
||||
environment: z.ZodEnum<["production", "preview"]>;
|
||||
production_branch: z.ZodOptional<z.ZodString>;
|
||||
deployment_trigger: z.ZodOptional<z.ZodObject<{
|
||||
metadata: z.ZodObject<{
|
||||
/** Commit hash of the deployment trigger metadata for the pages project */
|
||||
commit_hash: z.ZodString;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
commit_hash: string;
|
||||
}, {
|
||||
commit_hash: string;
|
||||
}>;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
metadata: {
|
||||
commit_hash: string;
|
||||
};
|
||||
}, {
|
||||
metadata: {
|
||||
commit_hash: string;
|
||||
};
|
||||
}>>;
|
||||
}>, "strip", z.ZodTypeAny, {
|
||||
type: "pages-deploy-detailed";
|
||||
environment: "production" | "preview";
|
||||
version: 1;
|
||||
pages_project: string | null;
|
||||
deployment_id: string | null;
|
||||
url?: string | undefined;
|
||||
alias?: string | undefined;
|
||||
production_branch?: string | undefined;
|
||||
deployment_trigger?: {
|
||||
metadata: {
|
||||
commit_hash: string;
|
||||
};
|
||||
} | undefined;
|
||||
}, {
|
||||
type: "pages-deploy-detailed";
|
||||
environment: "production" | "preview";
|
||||
version: 1;
|
||||
pages_project: string | null;
|
||||
deployment_id: string | null;
|
||||
url?: string | undefined;
|
||||
alias?: string | undefined;
|
||||
production_branch?: string | undefined;
|
||||
deployment_trigger?: {
|
||||
metadata: {
|
||||
commit_hash: string;
|
||||
};
|
||||
} | undefined;
|
||||
}>, z.ZodObject<z.objectUtil.extendShape<{
|
||||
version: z.ZodLiteral<1>;
|
||||
type: z.ZodString;
|
||||
}, {
|
||||
type: z.ZodLiteral<"deploy">;
|
||||
/** A list of URLs that represent the HTTP triggers associated with this deployment */
|
||||
/** basically, for wrangler-action purposes this is the deployment urls */
|
||||
targets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
||||
}>, "strip", z.ZodTypeAny, {
|
||||
type: "deploy";
|
||||
version: 1;
|
||||
targets?: string[] | undefined;
|
||||
}, {
|
||||
type: "deploy";
|
||||
version: 1;
|
||||
targets?: string[] | undefined;
|
||||
}>, z.ZodObject<z.objectUtil.extendShape<{
|
||||
version: z.ZodLiteral<1>;
|
||||
type: z.ZodString;
|
||||
}, {
|
||||
type: z.ZodLiteral<"version-upload">;
|
||||
/** The preview URL associated with this version upload */
|
||||
preview_url: z.ZodOptional<z.ZodString>;
|
||||
}>, "strip", z.ZodTypeAny, {
|
||||
type: "version-upload";
|
||||
version: 1;
|
||||
preview_url?: string | undefined;
|
||||
}, {
|
||||
type: "version-upload";
|
||||
version: 1;
|
||||
preview_url?: string | undefined;
|
||||
}>]>;
|
||||
/**
|
||||
* Parses file names in a directory to find wrangler artifact files
|
||||
*
|
||||
* @param artifactDirectory
|
||||
* @returns All artifact files from the directory
|
||||
*/
|
||||
export declare function getWranglerArtifacts(artifactDirectory: string): Promise<string[]>;
|
||||
/**
|
||||
* Searches for a supported wrangler OutputEntry
|
||||
*
|
||||
* @param artifactDirectory
|
||||
* @returns The first SupportedOutputEntry found within a wrangler artifact directory
|
||||
*/
|
||||
export declare function getOutputEntry(artifactDirectory: string): Promise<SupportedOutputEntry | null>;
|
||||
export {};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Generated
+1264
-2813
File diff suppressed because it is too large
Load Diff
+18
-12
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wrangler-action",
|
||||
"version": "3.4.1",
|
||||
"version": "3.13.1",
|
||||
"description": "GitHub Action to use [Wrangler](https://developers.cloudflare.com/workers/cli-wrangler/).",
|
||||
"author": "wrangler@cloudflare.com",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
@@ -29,18 +29,24 @@
|
||||
"check": "prettier --check ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/exec": "^1.1.1"
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@changesets/changelog-github": "^0.4.8",
|
||||
"@changesets/cli": "^2.26.2",
|
||||
"@cloudflare/workers-types": "^4.20231121.0",
|
||||
"@types/node": "^20.10.4",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"prettier": "^3.1.0",
|
||||
"semver": "^7.5.4",
|
||||
"typescript": "^5.3.3",
|
||||
"vitest": "^1.0.3"
|
||||
"@changesets/changelog-github": "^0.5.0",
|
||||
"@changesets/cli": "^2.27.12",
|
||||
"@cloudflare/workers-types": "^4.20241022.0",
|
||||
"@types/mock-fs": "^4.13.4",
|
||||
"@types/node": "^22.9.0",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@vercel/ncc": "^0.38.2",
|
||||
"mock-fs": "^5.4.1",
|
||||
"msw": "^2.6.4",
|
||||
"prettier": "^3.3.3",
|
||||
"semver": "^7.6.3",
|
||||
"typescript": "^5.6.3",
|
||||
"vitest": "^2.1.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
import { setOutput } from "@actions/core";
|
||||
import { info, WranglerActionConfig } from "./wranglerAction";
|
||||
import {
|
||||
getOutputEntry,
|
||||
OutputEntryDeployment,
|
||||
OutputEntryPagesDeployment,
|
||||
OutputEntryVersionUpload,
|
||||
} from "./wranglerArtifactManager";
|
||||
import { createGitHubDeploymentAndJobSummary } from "./service/github";
|
||||
|
||||
// fallback to trying to extract the deployment-url and pages-deployment-alias-url from stdout for wranglerVersion < 3.81.0
|
||||
function extractDeploymentUrlsFromStdout(stdOut: string): {
|
||||
deploymentUrl?: string;
|
||||
aliasUrl?: string;
|
||||
} {
|
||||
let deploymentUrl = "";
|
||||
let aliasUrl = "";
|
||||
|
||||
// Try to extract the deployment URL
|
||||
const deploymentUrlMatch = stdOut.match(/https?:\/\/[a-zA-Z0-9-./]+/);
|
||||
if (deploymentUrlMatch && deploymentUrlMatch[0]) {
|
||||
deploymentUrl = deploymentUrlMatch[0].trim();
|
||||
}
|
||||
|
||||
// And also try to extract the alias URL (since wrangler@3.78.0)
|
||||
const aliasUrlMatch = stdOut.match(/alias URL: (https?:\/\/[a-zA-Z0-9-./]+)/);
|
||||
if (aliasUrlMatch && aliasUrlMatch[1]) {
|
||||
aliasUrl = aliasUrlMatch[1].trim();
|
||||
}
|
||||
|
||||
return { deploymentUrl, aliasUrl };
|
||||
}
|
||||
|
||||
async function handlePagesDeployOutputEntry(
|
||||
config: WranglerActionConfig,
|
||||
pagesDeployOutputEntry: OutputEntryPagesDeployment,
|
||||
) {
|
||||
setOutput("deployment-url", pagesDeployOutputEntry.url);
|
||||
// DEPRECATED: deployment-alias-url in favour of pages-deployment-alias, drop in next wrangler-action major version change
|
||||
setOutput("deployment-alias-url", pagesDeployOutputEntry.alias);
|
||||
setOutput("pages-deployment-alias-url", pagesDeployOutputEntry.alias);
|
||||
setOutput("pages-deployment-id", pagesDeployOutputEntry.deployment_id);
|
||||
setOutput("pages-environment", pagesDeployOutputEntry.environment);
|
||||
|
||||
// Create github deployment, if GITHUB_TOKEN is present in config
|
||||
await createGitHubDeploymentAndJobSummary(config, pagesDeployOutputEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* If no wrangler output file found, fallback to extracting deployment-url from stdout.
|
||||
* @deprecated Use {@link handlePagesDeployOutputEntry} instead.
|
||||
*/
|
||||
function handlePagesDeployCommand(
|
||||
config: WranglerActionConfig,
|
||||
stdOut: string,
|
||||
) {
|
||||
info(
|
||||
config,
|
||||
"Unable to find a WRANGLER_OUTPUT_DIR, environment and id fields will be unavailable for output. Have you updated wrangler to version >=3.81.0?",
|
||||
);
|
||||
// DEPRECATED: deployment-alias-url in favour of pages-deployment-alias, drop in next wrangler-action major version change
|
||||
const { deploymentUrl, aliasUrl } = extractDeploymentUrlsFromStdout(stdOut);
|
||||
|
||||
setOutput("deployment-url", deploymentUrl);
|
||||
// DEPRECATED: deployment-alias-url in favour of pages-deployment-alias, drop in next wrangler-action major version change
|
||||
setOutput("deployment-alias-url", aliasUrl);
|
||||
setOutput("pages-deployment-alias-url", aliasUrl);
|
||||
}
|
||||
|
||||
function handleWranglerDeployOutputEntry(
|
||||
config: WranglerActionConfig,
|
||||
wranglerDeployOutputEntry: OutputEntryDeployment,
|
||||
) {
|
||||
// If no deployment urls found in wrangler output file, log that we couldn't find any urls and return.
|
||||
if (
|
||||
!wranglerDeployOutputEntry.targets ||
|
||||
wranglerDeployOutputEntry.targets.length === 0
|
||||
) {
|
||||
info(config, "No deployment-url found in wrangler deploy output file");
|
||||
return;
|
||||
}
|
||||
|
||||
// If more than 1 deployment url found, log that we're going to set deployment-url to the first match.
|
||||
// In a future wrangler-action version we should consider how we're going to output multiple deployment-urls
|
||||
if (wranglerDeployOutputEntry.targets.length > 1) {
|
||||
info(
|
||||
config,
|
||||
"Multiple deployment urls found in wrangler deploy output file, deployment-url will be set to the first url",
|
||||
);
|
||||
}
|
||||
|
||||
setOutput("deployment-url", wranglerDeployOutputEntry.targets[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* If no wrangler output file found, fallback to extracting deployment-url from stdout.
|
||||
* @deprecated Use {@link handleWranglerDeployOutputEntry} instead.
|
||||
*/
|
||||
function handleWranglerDeployCommand(
|
||||
config: WranglerActionConfig,
|
||||
stdOut: string,
|
||||
) {
|
||||
info(
|
||||
config,
|
||||
"Unable to find a WRANGLER_OUTPUT_DIR, deployment-url may have an unreliable output. Have you updated wrangler to version >=3.88.0?",
|
||||
);
|
||||
const { deploymentUrl } = extractDeploymentUrlsFromStdout(stdOut);
|
||||
setOutput("deployment-url", deploymentUrl);
|
||||
}
|
||||
|
||||
function handleVersionsUploadOutputEntry(
|
||||
versionsOutputEntry: OutputEntryVersionUpload,
|
||||
) {
|
||||
setOutput("deployment-url", versionsOutputEntry.preview_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* If no wrangler output file found, log a message stating deployment-url will be unavailable for output.
|
||||
* @deprecated Use {@link handleVersionsOutputEntry} instead.
|
||||
*/
|
||||
function handleVersionsOutputCommand(config: WranglerActionConfig) {
|
||||
info(
|
||||
config,
|
||||
"Unable to find a WRANGLER_OUTPUT_DIR, deployment-url will be unavailable for output. Have you updated wrangler to version >=3.88.0?",
|
||||
);
|
||||
}
|
||||
|
||||
function handleDeprectatedStdoutParsing(
|
||||
config: WranglerActionConfig,
|
||||
command: string,
|
||||
stdOut: string,
|
||||
) {
|
||||
// Check if this command is a pages deployment
|
||||
if (
|
||||
command.startsWith("pages deploy") ||
|
||||
command.startsWith("pages publish")
|
||||
) {
|
||||
handlePagesDeployCommand(config, stdOut);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this command is a workers deployment
|
||||
if (command.startsWith("deploy") || command.startsWith("publish")) {
|
||||
handleWranglerDeployCommand(config, stdOut);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this command is a versions deployment
|
||||
if (command.startsWith("versions upload")) {
|
||||
handleVersionsOutputCommand(config);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
export async function handleCommandOutputParsing(
|
||||
config: WranglerActionConfig,
|
||||
command: string,
|
||||
stdOut: string,
|
||||
) {
|
||||
// get first OutputEntry found within wrangler artifact output directory
|
||||
const outputEntry = await getOutputEntry(config.WRANGLER_OUTPUT_DIR);
|
||||
|
||||
if (outputEntry === null) {
|
||||
// if no outputEntry found, fallback to deprecated stdOut parsing
|
||||
handleDeprectatedStdoutParsing(config, command, stdOut);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (outputEntry.type) {
|
||||
case "pages-deploy-detailed":
|
||||
await handlePagesDeployOutputEntry(config, outputEntry);
|
||||
break;
|
||||
case "deploy":
|
||||
handleWranglerDeployOutputEntry(config, outputEntry);
|
||||
break;
|
||||
case "version-upload":
|
||||
handleVersionsUploadOutputEntry(outputEntry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -43,7 +43,7 @@ export async function execShell(
|
||||
|
||||
await promise;
|
||||
return child.exitCode;
|
||||
} catch (err: any) {
|
||||
} catch (err) {
|
||||
if (isExecAsyncException(err)) {
|
||||
process.stderr.write(err.stderr);
|
||||
throw new Error(`Process failed with exit code ${err.code}`);
|
||||
|
||||
+14
-283
@@ -1,26 +1,18 @@
|
||||
import {
|
||||
getBooleanInput,
|
||||
getInput,
|
||||
getMultilineInput,
|
||||
endGroup as originalEndGroup,
|
||||
error as originalError,
|
||||
info as originalInfo,
|
||||
debug,
|
||||
startGroup as originalStartGroup,
|
||||
setFailed,
|
||||
setOutput,
|
||||
} from "@actions/core";
|
||||
import { exec, execShell } from "./exec";
|
||||
import { checkWorkingDirectory, semverCompare } from "./utils";
|
||||
import { getBooleanInput, getInput, getMultilineInput } from "@actions/core";
|
||||
import { tmpdir } from "os";
|
||||
import { join } from "path";
|
||||
import { getPackageManager } from "./packageManagers";
|
||||
import { checkWorkingDirectory } from "./utils";
|
||||
import { main, WranglerActionConfig } from "./wranglerAction";
|
||||
|
||||
const DEFAULT_WRANGLER_VERSION = "3.13.2";
|
||||
const DEFAULT_WRANGLER_VERSION = "3.90.0";
|
||||
|
||||
/**
|
||||
* A configuration object that contains all the inputs & immutable state for the action.
|
||||
*/
|
||||
const config = {
|
||||
const config: WranglerActionConfig = {
|
||||
WRANGLER_VERSION: getInput("wranglerVersion") || DEFAULT_WRANGLER_VERSION,
|
||||
didUserProvideWranglerVersion: Boolean(getInput("wranglerVersion")),
|
||||
secrets: getMultilineInput("secrets"),
|
||||
workingDirectory: checkWorkingDirectory(getInput("workingDirectory")),
|
||||
CLOUDFLARE_API_TOKEN: getInput("apiToken"),
|
||||
@@ -30,276 +22,15 @@ const config = {
|
||||
COMMANDS: getMultilineInput("command"),
|
||||
QUIET_MODE: getBooleanInput("quiet"),
|
||||
PACKAGE_MANAGER: getInput("packageManager"),
|
||||
WRANGLER_OUTPUT_DIR: `${join(
|
||||
tmpdir(),
|
||||
`wranglerArtifacts-${crypto.randomUUID()}`,
|
||||
)}`,
|
||||
GITHUB_TOKEN: getInput("gitHubToken", { required: false }),
|
||||
} as const;
|
||||
|
||||
const packageManager = getPackageManager(config.PACKAGE_MANAGER, {
|
||||
workingDirectory: config.workingDirectory,
|
||||
});
|
||||
|
||||
function info(message: string, bypass?: boolean): void {
|
||||
if (!config.QUIET_MODE || bypass) {
|
||||
originalInfo(message);
|
||||
}
|
||||
}
|
||||
|
||||
function error(message: string, bypass?: boolean): void {
|
||||
if (!config.QUIET_MODE || bypass) {
|
||||
originalError(message);
|
||||
}
|
||||
}
|
||||
|
||||
function startGroup(name: string): void {
|
||||
if (!config.QUIET_MODE) {
|
||||
originalStartGroup(name);
|
||||
}
|
||||
}
|
||||
|
||||
function endGroup(): void {
|
||||
if (!config.QUIET_MODE) {
|
||||
originalEndGroup();
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
authenticationSetup();
|
||||
await installWrangler();
|
||||
await execCommands(getMultilineInput("preCommands"), "pre");
|
||||
await uploadSecrets();
|
||||
await wranglerCommands();
|
||||
await execCommands(getMultilineInput("postCommands"), "post");
|
||||
info("🏁 Wrangler Action completed", true);
|
||||
} catch (err: unknown) {
|
||||
err instanceof Error && error(err.message);
|
||||
setFailed("🚨 Action failed");
|
||||
}
|
||||
}
|
||||
|
||||
async function installWrangler() {
|
||||
if (config["WRANGLER_VERSION"].startsWith("1")) {
|
||||
throw new Error(
|
||||
`Wrangler v1 is no longer supported by this action. Please use major version 2 or greater`,
|
||||
);
|
||||
}
|
||||
|
||||
startGroup("📥 Installing Wrangler");
|
||||
try {
|
||||
await exec(
|
||||
packageManager.install,
|
||||
[`wrangler@${config["WRANGLER_VERSION"]}`],
|
||||
{
|
||||
cwd: config["workingDirectory"],
|
||||
silent: config["QUIET_MODE"],
|
||||
},
|
||||
);
|
||||
|
||||
info(`✅ Wrangler installed`, true);
|
||||
} finally {
|
||||
endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
function authenticationSetup() {
|
||||
process.env.CLOUDFLARE_API_TOKEN = config["CLOUDFLARE_API_TOKEN"];
|
||||
process.env.CLOUDFLARE_ACCOUNT_ID = config["CLOUDFLARE_ACCOUNT_ID"];
|
||||
}
|
||||
|
||||
async function execCommands(commands: string[], cmdType: string) {
|
||||
if (!commands.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
startGroup(`🚀 Running ${cmdType}Commands`);
|
||||
try {
|
||||
for (const command of commands) {
|
||||
const cmd = command.startsWith("wrangler")
|
||||
? `${packageManager.exec} ${command}`
|
||||
: command;
|
||||
|
||||
await execShell(cmd, {
|
||||
cwd: config["workingDirectory"],
|
||||
silent: config["QUIET_MODE"],
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
function getSecret(secret: string) {
|
||||
if (!secret) {
|
||||
throw new Error("Secret name cannot be blank.");
|
||||
}
|
||||
|
||||
const value = process.env[secret];
|
||||
if (!value) {
|
||||
throw new Error(`Value for secret ${secret} not found in environment.`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function getEnvVar(envVar: string) {
|
||||
if (!envVar) {
|
||||
throw new Error("Var name cannot be blank.");
|
||||
}
|
||||
|
||||
const value = process.env[envVar];
|
||||
if (!value) {
|
||||
throw new Error(`Value for var ${envVar} not found in environment.`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function legacyUploadSecrets(
|
||||
secrets: string[],
|
||||
environment?: string,
|
||||
workingDirectory?: string,
|
||||
) {
|
||||
return Promise.all(
|
||||
secrets.map((secret) => {
|
||||
const args = ["wrangler", "secret", "put", secret];
|
||||
if (environment) {
|
||||
args.push("--env", environment);
|
||||
}
|
||||
return exec(packageManager.exec, args, {
|
||||
cwd: workingDirectory,
|
||||
silent: config["QUIET_MODE"],
|
||||
input: Buffer.from(getSecret(secret)),
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async function uploadSecrets() {
|
||||
const secrets: string[] = config["secrets"];
|
||||
const environment = config["ENVIRONMENT"];
|
||||
const workingDirectory = config["workingDirectory"];
|
||||
|
||||
if (!secrets.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
startGroup("🔑 Uploading secrets...");
|
||||
|
||||
try {
|
||||
if (semverCompare(config["WRANGLER_VERSION"], "3.4.0")) {
|
||||
return legacyUploadSecrets(secrets, environment, workingDirectory);
|
||||
}
|
||||
|
||||
const args = ["wrangler", "secret:bulk"];
|
||||
|
||||
if (environment) {
|
||||
args.push("--env", environment);
|
||||
}
|
||||
|
||||
await exec(packageManager.exec, args, {
|
||||
cwd: workingDirectory,
|
||||
silent: config["QUIET_MODE"],
|
||||
input: Buffer.from(
|
||||
JSON.stringify(
|
||||
Object.fromEntries(
|
||||
secrets.map((secret) => [secret, getSecret(secret)]),
|
||||
),
|
||||
),
|
||||
),
|
||||
});
|
||||
} catch (err: unknown) {
|
||||
if (err instanceof Error) {
|
||||
error(err.message);
|
||||
err.stack && debug(err.stack);
|
||||
}
|
||||
throw new Error(`Failed to upload secrets.`);
|
||||
} finally {
|
||||
endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
async function wranglerCommands() {
|
||||
startGroup("🚀 Running Wrangler Commands");
|
||||
try {
|
||||
const commands = config["COMMANDS"];
|
||||
const environment = config["ENVIRONMENT"];
|
||||
|
||||
if (!commands.length) {
|
||||
const wranglerVersion = config["WRANGLER_VERSION"];
|
||||
const deployCommand = semverCompare("2.20.0", wranglerVersion)
|
||||
? "deploy"
|
||||
: "publish";
|
||||
commands.push(deployCommand);
|
||||
}
|
||||
|
||||
for (let command of commands) {
|
||||
const args = [];
|
||||
|
||||
if (environment && !command.includes("--env")) {
|
||||
args.push("--env", environment);
|
||||
}
|
||||
|
||||
if (
|
||||
config["VARS"].length &&
|
||||
(command.startsWith("deploy") || command.startsWith("publish")) &&
|
||||
!command.includes("--var")
|
||||
) {
|
||||
args.push("--var");
|
||||
for (const v of config["VARS"]) {
|
||||
args.push(`${v}:${getEnvVar(v)}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Used for saving the wrangler output
|
||||
let stdOut = "";
|
||||
let stdErr = "";
|
||||
|
||||
// Construct the options for the exec command
|
||||
const options = {
|
||||
cwd: config["workingDirectory"],
|
||||
silent: config["QUIET_MODE"],
|
||||
listeners: {
|
||||
stdout: (data: Buffer) => {
|
||||
stdOut += data.toString();
|
||||
},
|
||||
stderr: (data: Buffer) => {
|
||||
stdErr += data.toString();
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Execute the wrangler command
|
||||
await exec(`${packageManager.exec} wrangler ${command}`, args, options);
|
||||
|
||||
// Set the outputs for the command
|
||||
setOutput("command-output", stdOut);
|
||||
setOutput("command-stderr", stdErr);
|
||||
|
||||
// Check if this command is a workers or pages deployment
|
||||
if (
|
||||
command.startsWith("deploy") ||
|
||||
command.startsWith("publish") ||
|
||||
command.startsWith("pages publish") ||
|
||||
command.startsWith("pages deploy")
|
||||
) {
|
||||
// If this is a workers or pages deployment, try to extract the deployment URL
|
||||
let deploymentUrl = "";
|
||||
const deploymentUrlMatch = stdOut.match(/https?:\/\/[a-zA-Z0-9-./]+/);
|
||||
if (deploymentUrlMatch && deploymentUrlMatch[0]) {
|
||||
deploymentUrl = deploymentUrlMatch[0].trim();
|
||||
setOutput("deployment-url", deploymentUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
export {
|
||||
authenticationSetup,
|
||||
execCommands,
|
||||
installWrangler,
|
||||
uploadSecrets,
|
||||
wranglerCommands,
|
||||
};
|
||||
main(config, packageManager);
|
||||
|
||||
+62
-46
@@ -3,92 +3,108 @@ import { getPackageManager } from "./packageManagers";
|
||||
|
||||
describe("getPackageManager", () => {
|
||||
test("should use provided value instead of inferring from lockfile", () => {
|
||||
expect(getPackageManager("npm", { workingDirectory: "test/npm" }))
|
||||
.toMatchInlineSnapshot(`
|
||||
expect(
|
||||
getPackageManager("npm", { workingDirectory: "src/test/fixtures/npm" }),
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "npx",
|
||||
"execNoInstall": "npx --no-install",
|
||||
"install": "npm i",
|
||||
}
|
||||
`);
|
||||
|
||||
expect(getPackageManager("yarn", { workingDirectory: "test/npm" }))
|
||||
.toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "yarn",
|
||||
"install": "yarn add",
|
||||
}
|
||||
`);
|
||||
expect(
|
||||
getPackageManager("yarn", { workingDirectory: "src/test/fixtures/npm" }),
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "yarn",
|
||||
"execNoInstall": "yarn",
|
||||
"install": "yarn add",
|
||||
}
|
||||
`);
|
||||
|
||||
expect(getPackageManager("pnpm", { workingDirectory: "test/npm" }))
|
||||
.toMatchInlineSnapshot(`
|
||||
expect(
|
||||
getPackageManager("pnpm", { workingDirectory: "src/test/fixtures/npm" }),
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "pnpm exec",
|
||||
"execNoInstall": "pnpm exec",
|
||||
"install": "pnpm add",
|
||||
}
|
||||
`);
|
||||
|
||||
expect(getPackageManager("bun", { workingDirectory: "test/bun" }))
|
||||
.toMatchInlineSnapshot(`
|
||||
expect(
|
||||
getPackageManager("bun", { workingDirectory: "src/test/fixtures/bun" }),
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "bunx",
|
||||
"execNoInstall": "bun run",
|
||||
"install": "bun i",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test("should use npm if no value provided and package-lock.json exists", () => {
|
||||
expect(getPackageManager("", { workingDirectory: "test/npm" }))
|
||||
expect(getPackageManager("", { workingDirectory: "src/test/fixtures/npm" }))
|
||||
.toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "npx",
|
||||
"install": "npm i",
|
||||
}
|
||||
`);
|
||||
{
|
||||
"exec": "npx",
|
||||
"execNoInstall": "npx --no-install",
|
||||
"install": "npm i",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test("should use yarn if no value provided and yarn.lock exists", () => {
|
||||
expect(getPackageManager("", { workingDirectory: "test/yarn" }))
|
||||
.toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "yarn",
|
||||
"install": "yarn add",
|
||||
}
|
||||
`);
|
||||
expect(
|
||||
getPackageManager("", { workingDirectory: "src/test/fixtures/yarn" }),
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "yarn",
|
||||
"execNoInstall": "yarn",
|
||||
"install": "yarn add",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test("should use pnpm if no value provided and pnpm-lock.yaml exists", () => {
|
||||
expect(getPackageManager("", { workingDirectory: "test/pnpm" }))
|
||||
.toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "pnpm exec",
|
||||
"install": "pnpm add",
|
||||
}
|
||||
`);
|
||||
expect(
|
||||
getPackageManager("", { workingDirectory: "src/test/fixtures/pnpm" }),
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "pnpm exec",
|
||||
"execNoInstall": "pnpm exec",
|
||||
"install": "pnpm add",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test("should use bun if no value provided and bun.lockb exists", () => {
|
||||
expect(getPackageManager("", { workingDirectory: "test/bun" }))
|
||||
expect(getPackageManager("", { workingDirectory: "src/test/fixtures/bun" }))
|
||||
.toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "bunx",
|
||||
"install": "bun i",
|
||||
}
|
||||
{
|
||||
"exec": "bunx",
|
||||
"execNoInstall": "bun run",
|
||||
"install": "bun i",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test("should use npm if no value provided and no lockfile is present", () => {
|
||||
expect(getPackageManager("", { workingDirectory: "test/empty" }))
|
||||
.toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "npx",
|
||||
"install": "npm i",
|
||||
}
|
||||
`);
|
||||
expect(
|
||||
getPackageManager("", { workingDirectory: "src/test/fixtures/empty" }),
|
||||
).toMatchInlineSnapshot(`
|
||||
{
|
||||
"exec": "npx",
|
||||
"execNoInstall": "npx --no-install",
|
||||
"install": "npm i",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test("should throw if an invalid value is provided", () => {
|
||||
expect(() =>
|
||||
getPackageManager("cargo", { workingDirectory: "test/npm" }),
|
||||
getPackageManager("cargo", { workingDirectory: "src/test/fixtures/npm" }),
|
||||
).toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
+10
-2
@@ -1,27 +1,32 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import * as path from "node:path";
|
||||
|
||||
interface PackageManager {
|
||||
export interface PackageManager {
|
||||
install: string;
|
||||
exec: string;
|
||||
execNoInstall: string;
|
||||
}
|
||||
|
||||
const PACKAGE_MANAGERS = {
|
||||
npm: {
|
||||
install: "npm i",
|
||||
exec: "npx",
|
||||
execNoInstall: "npx --no-install",
|
||||
},
|
||||
yarn: {
|
||||
install: "yarn add",
|
||||
exec: "yarn",
|
||||
execNoInstall: "yarn",
|
||||
},
|
||||
pnpm: {
|
||||
install: "pnpm add",
|
||||
exec: "pnpm exec",
|
||||
execNoInstall: "pnpm exec",
|
||||
},
|
||||
bun: {
|
||||
install: "bun i",
|
||||
exec: "bunx",
|
||||
execNoInstall: "bun run",
|
||||
},
|
||||
} as const satisfies Readonly<Record<string, PackageManager>>;
|
||||
|
||||
@@ -39,7 +44,10 @@ function detectPackageManager(
|
||||
if (existsSync(path.join(workingDirectory, "pnpm-lock.yaml"))) {
|
||||
return "pnpm";
|
||||
}
|
||||
if (existsSync(path.join(workingDirectory, "bun.lockb"))) {
|
||||
if (
|
||||
existsSync(path.join(workingDirectory, "bun.lockb")) ||
|
||||
existsSync(path.join(workingDirectory, "bun.lock"))
|
||||
) {
|
||||
return "bun";
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { setupServer } from "msw/node";
|
||||
import { createGitHubDeployment, createJobSummary } from "./github";
|
||||
import { getOctokit } from "@actions/github";
|
||||
import { mockGithubDeployments } from "../test/mocks";
|
||||
import { getTestConfig } from "../test/test-utils";
|
||||
import mockfs from "mock-fs";
|
||||
import { readFile } from "fs/promises";
|
||||
|
||||
afterEach(() => {
|
||||
mockfs.restore();
|
||||
});
|
||||
|
||||
describe("github", () => {
|
||||
it("Calls createGitHubDeployment successfully", async () => {
|
||||
const githubUser = "mock-user";
|
||||
const githubRepoName = "wrangler-action";
|
||||
const server = setupServer(
|
||||
...mockGithubDeployments({ githubUser, githubRepoName }).handlers,
|
||||
);
|
||||
server.listen({ onUnhandledRequest: "error" });
|
||||
vi.stubEnv("GITHUB_REPOSITORY", `${githubUser}/${githubRepoName}`);
|
||||
|
||||
const testConfig = getTestConfig();
|
||||
const octokit = getOctokit(testConfig.GITHUB_TOKEN, { request: fetch });
|
||||
await createGitHubDeployment({
|
||||
config: testConfig,
|
||||
octokit,
|
||||
productionBranch: "production-branch",
|
||||
deploymentId: "fake-deployment-id",
|
||||
projectName: "fake-project-name",
|
||||
deploymentUrl: "https://fake-deployment-url.com",
|
||||
environment: "production",
|
||||
});
|
||||
server.close();
|
||||
});
|
||||
it("Calls createJobSummary successfully", async () => {
|
||||
vi.stubEnv("GITHUB_STEP_SUMMARY", "summary");
|
||||
mockfs({
|
||||
summary: mockfs.file(),
|
||||
});
|
||||
await createJobSummary({
|
||||
commitHash: "fake-commit-hash",
|
||||
deploymentUrl: "https://fake-deployment-url.com",
|
||||
aliasUrl: "https://fake-alias-url.com",
|
||||
});
|
||||
expect((await readFile("summary")).toString()).toMatchInlineSnapshot(`
|
||||
"
|
||||
# Deploying with Cloudflare Pages
|
||||
|
||||
| Name | Result |
|
||||
| ----------------------- | - |
|
||||
| **Last commit:** | fake-commit-hash |
|
||||
| **Preview URL**: | https://fake-deployment-url.com |
|
||||
| **Branch Preview URL**: | https://fake-alias-url.com |
|
||||
"
|
||||
`);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,128 @@
|
||||
import { summary } from "@actions/core";
|
||||
import { context, getOctokit } from "@actions/github";
|
||||
import { env } from "process";
|
||||
import { info, warn } from "../utils";
|
||||
import { OutputEntryPagesDeployment } from "../wranglerArtifactManager";
|
||||
import { WranglerActionConfig } from "../wranglerAction";
|
||||
|
||||
type Octokit = ReturnType<typeof getOctokit>;
|
||||
|
||||
export async function createGitHubDeployment({
|
||||
config,
|
||||
octokit,
|
||||
productionBranch,
|
||||
environment,
|
||||
deploymentId,
|
||||
projectName,
|
||||
deploymentUrl,
|
||||
}: {
|
||||
config: WranglerActionConfig;
|
||||
octokit: Octokit;
|
||||
productionBranch: string;
|
||||
environment: string;
|
||||
deploymentId: string | null;
|
||||
projectName: string;
|
||||
deploymentUrl?: string;
|
||||
}) {
|
||||
const githubBranch = env.GITHUB_HEAD_REF || env.GITHUB_REF_NAME;
|
||||
const productionEnvironment = githubBranch === productionBranch;
|
||||
|
||||
const deployment = await octokit.rest.repos.createDeployment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: githubBranch || context.ref,
|
||||
auto_merge: false,
|
||||
description: "Cloudflare Pages",
|
||||
required_contexts: [],
|
||||
environment,
|
||||
production_environment: productionEnvironment,
|
||||
});
|
||||
|
||||
if (deployment.status !== 201) {
|
||||
info(config, "Error creating GitHub deployment");
|
||||
return;
|
||||
}
|
||||
await octokit.rest.repos.createDeploymentStatus({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
deployment_id: deployment.data.id,
|
||||
environment,
|
||||
environment_url: deploymentUrl,
|
||||
production_environment: productionEnvironment,
|
||||
// don't have project_name or deployment_id I think
|
||||
log_url: `https://dash.cloudflare.com/${config.CLOUDFLARE_ACCOUNT_ID}/pages/view/${projectName}/${deploymentId}`,
|
||||
description: "Cloudflare Pages",
|
||||
state: "success",
|
||||
auto_inactive: false,
|
||||
});
|
||||
}
|
||||
|
||||
export async function createJobSummary({
|
||||
commitHash,
|
||||
deploymentUrl,
|
||||
aliasUrl,
|
||||
}: {
|
||||
commitHash: string;
|
||||
deploymentUrl?: string;
|
||||
aliasUrl?: string;
|
||||
}) {
|
||||
await summary
|
||||
.addRaw(
|
||||
`
|
||||
# Deploying with Cloudflare Pages
|
||||
|
||||
| Name | Result |
|
||||
| ----------------------- | - |
|
||||
| **Last commit:** | ${commitHash} |
|
||||
| **Preview URL**: | ${deploymentUrl} |
|
||||
| **Branch Preview URL**: | ${aliasUrl} |
|
||||
`,
|
||||
)
|
||||
.write();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create github deployment, if GITHUB_TOKEN is present in config
|
||||
*/
|
||||
export async function createGitHubDeploymentAndJobSummary(
|
||||
config: WranglerActionConfig,
|
||||
pagesArtifactFields: OutputEntryPagesDeployment,
|
||||
) {
|
||||
if (
|
||||
config.GITHUB_TOKEN &&
|
||||
pagesArtifactFields.production_branch &&
|
||||
pagesArtifactFields.pages_project &&
|
||||
pagesArtifactFields.deployment_trigger
|
||||
) {
|
||||
const octokit = getOctokit(config.GITHUB_TOKEN);
|
||||
const [createGitHubDeploymentRes, createJobSummaryRes] =
|
||||
await Promise.allSettled([
|
||||
createGitHubDeployment({
|
||||
config,
|
||||
octokit,
|
||||
deploymentUrl: pagesArtifactFields.url,
|
||||
productionBranch: pagesArtifactFields.production_branch,
|
||||
environment: pagesArtifactFields.environment,
|
||||
deploymentId: pagesArtifactFields.deployment_id,
|
||||
projectName: pagesArtifactFields.pages_project,
|
||||
}),
|
||||
createJobSummary({
|
||||
commitHash:
|
||||
pagesArtifactFields.deployment_trigger.metadata.commit_hash.substring(
|
||||
0,
|
||||
8,
|
||||
),
|
||||
deploymentUrl: pagesArtifactFields.url,
|
||||
aliasUrl: pagesArtifactFields.alias,
|
||||
}),
|
||||
]);
|
||||
|
||||
if (createGitHubDeploymentRes.status === "rejected") {
|
||||
warn(config, "Creating Github Deployment failed");
|
||||
}
|
||||
|
||||
if (createJobSummaryRes.status === "rejected") {
|
||||
warn(config, "Creating Github Job summary failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ export default {
|
||||
return new Response("OK");
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
return Response.json({
|
||||
...request,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
name = "wrangler-action-test-build-quiet"
|
||||
main = "./index.ts"
|
||||
compatibility_date = "2023-07-07"
|
||||
workers_dev = true
|
||||
@@ -17,7 +17,6 @@ export default {
|
||||
return new Response("OK");
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
return Response.json({
|
||||
...request,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
@@ -12,7 +12,6 @@ export default {
|
||||
return new Response(`${SECRET1} ${SECRET2}`);
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
return Response.json({
|
||||
...request,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
Generated
Vendored
@@ -17,7 +17,6 @@ export default {
|
||||
return new Response("OK");
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
return Response.json({
|
||||
...request,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
@@ -17,7 +17,6 @@ export default {
|
||||
return new Response("OK");
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
return Response.json({
|
||||
...request,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "wrangler-action-test",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wrangler-action-test"
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "wrangler-action-test",
|
||||
"license": "MIT",
|
||||
"private": true
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
name = "wrangler-action-test"
|
||||
name = "wrangler-action-test-only-build"
|
||||
main = "./index.ts"
|
||||
compatibility_date = "2023-07-07"
|
||||
workers_dev = true
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
|
||||
export default {
|
||||
fetch(request: Request, env: Env) {
|
||||
const url = new URL(request.url);
|
||||
|
||||
if (url.pathname === "/secret-health-check") {
|
||||
const { SECRET1, SECRET2 } = env;
|
||||
|
||||
if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") {
|
||||
throw new Error("SECRET1 or SECRET2 is not defined");
|
||||
}
|
||||
|
||||
return new Response("OK");
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
...request,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
|
||||
export default {
|
||||
fetch(request: Request, env: Env) {
|
||||
const url = new URL(request.url);
|
||||
|
||||
if (url.pathname === "/secret-health-check") {
|
||||
const { SECRET1, SECRET2 } = env;
|
||||
|
||||
if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") {
|
||||
throw new Error("SECRET1 or SECRET2 is not defined");
|
||||
}
|
||||
|
||||
return new Response("OK");
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
...request,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
});
|
||||
},
|
||||
};
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
|
||||
const args = Array.from(process.argv);
|
||||
const command = args.pop();
|
||||
switch (command) {
|
||||
case "--version":
|
||||
console.log(`
|
||||
⛅️ wrangler 1.1.1 (update available 1.2.3)
|
||||
------------------------------------------`);
|
||||
process.exit(0);
|
||||
case "action-test":
|
||||
console.log("Test successful.");
|
||||
process.exit(0);
|
||||
default:
|
||||
console.error("Invalid command");
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "wrangler",
|
||||
"version": "1.1.1",
|
||||
"main": "index.js",
|
||||
"bin": "index.js"
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "wrangler-action-pre-installed-wrangler-test",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wrangler-action-pre-installed-wrangler-test",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"wrangler": "file:mock_packages/wrangler"
|
||||
}
|
||||
},
|
||||
"mock_packages/wrangler": {
|
||||
"version": "1.1.1",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"wrangler": "index.js"
|
||||
}
|
||||
},
|
||||
"node_modules/wrangler": {
|
||||
"resolved": "mock_packages/wrangler",
|
||||
"link": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"wrangler": {
|
||||
"version": "file:mock_packages/wrangler"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "wrangler-action-pre-installed-wrangler-test",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"wrangler": "file:mock_packages/wrangler"
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
|
||||
export default {
|
||||
fetch(request: Request, env: Env) {
|
||||
const url = new URL(request.url);
|
||||
|
||||
if (url.pathname === "/secret-health-check") {
|
||||
const { SECRET1, SECRET2 } = env;
|
||||
|
||||
if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") {
|
||||
throw new Error("SECRET1 or SECRET2 is not defined");
|
||||
}
|
||||
|
||||
return new Response("OK");
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
...request,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
});
|
||||
},
|
||||
};
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "wrangler-action-test",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wrangler-action-test"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "wrangler-action-test",
|
||||
"license": "MIT",
|
||||
"private": true
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
name = "wrangler-action-test-secrets-default"
|
||||
main = "./index.ts"
|
||||
compatibility_date = "2023-07-07"
|
||||
workers_dev = true
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
|
||||
export default {
|
||||
fetch(request: Request, env: Env) {
|
||||
const url = new URL(request.url);
|
||||
|
||||
if (url.pathname === "/secret-health-check") {
|
||||
const { SECRET1, SECRET2 } = env;
|
||||
|
||||
if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") {
|
||||
throw new Error("SECRET1 or SECRET2 is not defined");
|
||||
}
|
||||
|
||||
return new Response("OK");
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
...request,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
});
|
||||
},
|
||||
};
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "wrangler-action-test",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wrangler-action-test"
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "wrangler-action-test",
|
||||
"license": "MIT",
|
||||
"private": true
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
name = "wrangler-action-test"
|
||||
name = "wrangler-action-test-secrets-v2"
|
||||
main = "./index.ts"
|
||||
compatibility_date = "2023-07-07"
|
||||
workers_dev = true
|
||||
@@ -0,0 +1,4 @@
|
||||
name = "wrangler-action-test-specify-package-manager"
|
||||
main = "./index.ts"
|
||||
compatibility_date = "2023-07-07"
|
||||
workers_dev = true
|
||||
@@ -0,0 +1 @@
|
||||
export default {};
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "wrangler-action-detect-package-manager-test",
|
||||
"license": "MIT",
|
||||
"private": true
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
name = "wrangler-action-test-unspecified-package-manager"
|
||||
main = "./index.ts"
|
||||
compatibility_date = "2023-07-07"
|
||||
workers_dev = true
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
type Env = {
|
||||
SECRET1?: string;
|
||||
SECRET2?: string;
|
||||
};
|
||||
|
||||
export default {
|
||||
fetch(request: Request, env: Env) {
|
||||
const url = new URL(request.url);
|
||||
|
||||
if (url.pathname === "/secret-health-check") {
|
||||
const { SECRET1, SECRET2 } = env;
|
||||
|
||||
if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") {
|
||||
throw new Error("SECRET1 or SECRET2 is not defined");
|
||||
}
|
||||
|
||||
return new Response("OK");
|
||||
}
|
||||
|
||||
return Response.json({
|
||||
...request,
|
||||
headers: Object.fromEntries(request.headers),
|
||||
});
|
||||
},
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user