Compare commits

...

65 Commits

Author SHA1 Message Date
github-actions[bot] 1c594e88da Automatic compilation 2023-08-09 16:32:54 +00:00
Jacob M-G Evans e420d29d0a Updating build script to convert to .mjs for ESM support 2023-08-09 11:19:52 -05:00
Jacob M-G Evans d05a65f82b Merge pull request #129 from cloudflare/jacobmgevans/README-action-update
Update README with newer version of checkout action
2023-08-08 15:13:50 -05:00
Jacob M-G Evans c9da75b82e Update README with newer version of checkout action 2023-08-08 15:13:05 -05:00
Jacob M-G Evans 29cef5effc Merge pull request #131 from cloudflare/jacobmgevans/action-permissions
Add permissions to Action
2023-08-08 14:51:16 -05:00
Jacob M-G Evans ee60b7bd5e Add permissions to Action 2023-08-08 14:50:15 -05:00
Jacob M-G Evans 0ab3500d54 Merge pull request #128 from cloudflare/jacobmgevans/automate-action-publish
Automate Action Release
2023-08-08 14:14:19 -05:00
Jacob M-G Evans dfa59a861f start script not needed, using Act locally 2023-08-08 13:28:05 -05:00
Jacob M-G Evans 342e6243b7 remove dist & node_modules from repo 2023-08-08 13:21:44 -05:00
Jacob M-G Evans d6590f86f4 Automate Action Release
Utilizing build & tag action to automate the deps and build steps for releasing the Action. Additionally using NCC for the build process to easy compile the deps into a small executable with the JS file.
2023-08-08 13:03:11 -05:00
Jacob M-G Evans 97e54f3396 Merge pull request #127 from cloudflare/lrapoport/add-issues-to-gh-project
Automatically add issues to workers-sdk GH project
2023-08-08 08:35:11 -05:00
lrapoport-cf f85e1acfa7 Add workflow to add issues to GH project 2023-08-07 22:10:59 -04:00
lrapoport-cf e18e1dfc82 Merge pull request #124 from cloudflare/lrapoport/publish-to-deploy
Update publish to deploy
2023-08-07 16:31:50 -04:00
Jacob M-G Evans 20ea506049 Temp fix for deps issue 2023-08-07 15:11:15 -05:00
lrapoport-cf 45c57ae013 Update publish to deploy 2023-08-07 15:57:12 -04:00
Jacob M-G Evans a5fd4fdd34 Merge pull request #121 from cloudflare/jacobmgevans/codeowners
Owners: Wrangler Team
2023-08-07 14:42:13 -05:00
Jacob M-G Evans 002bb083fa Update README.md
Co-authored-by: lrapoport-cf <107272160+lrapoport-cf@users.noreply.github.com>
2023-08-07 14:42:06 -05:00
Jacob M-G Evans 42c609b2d6 included README update 2023-08-07 14:29:10 -05:00
Jacob M-G Evans c8f756bccf Fix Prettier check with /dist 2023-08-07 14:23:56 -05:00
Jacob M-G Evans 81fb6a9681 Owners: Wrangler Team 2023-08-07 14:11:03 -05:00
Jacob M-G Evans 6231e31709 hotfix missing dist 2023-08-07 14:06:55 -05:00
Jacob M-G Evans 0c419bee6c Merge pull request #119 from cloudflare/jacobmgevans/remove-v1-examples
Update README to remove v1 suggestions/examples
2023-08-07 13:30:09 -05:00
Jacob M-G Evans 74a9b9885f Update README to remove v1 suggestions/examples 2023-08-07 13:18:56 -05:00
Jacob M-G Evans 3dd57ff2bb Merge pull request #112 from cloudflare/jacobmgevans/typescript-overhaul
v4 w/ TypeScript Overhaul
2023-08-07 13:08:09 -05:00
Jacob M-G Evans edb2a58814 feat: rewrite Wrangler Action in TypeScript
* Removes dependencies such as Docker, decreasing spin-up time
* Adds community-requested features, including bulk secrets API utilization from Wrangler
* Fixes CI/CD
* Adds testing
* Improves command implementation
* Begins using Node for the Action engine/runner
* Openly discusses all changes with the community
  GitHub Discussions opened and Issues monitored

BREAKING CHANGES:
* Docker is no longer a dependency
* Wrangler v1 is no longer supported

Additional related Internal tickets:
Major Version Default: https://jira.cfdata.org/browse/DEVX-632
Rewrite Project: DEVX-804,802,800,632
2023-08-07 13:05:09 -05:00
Sunil Pai 4c10c1822a Merge pull request #72 from WalshyDev/walshy/pages-996-support-wrangler2
Support wrangler2 - v2
2022-05-09 12:02:45 +01:00
Daniel Walsh 3d1979ca8e Support wrangler2 - v2.0.0 2022-05-09 11:49:03 +01:00
Adam Janiš 6f62debcf8 Merge pull request #56 from ItalyPaleAle/patch-1
Update Node.js to 16
2022-03-15 12:30:29 +01:00
Kristian Freeman 006366c1ae Merge pull request #46 from whoabuddy/patch-1
Update README.md release version
2021-07-19 10:19:25 -05:00
Alessandro (Ale) Segala 95ac136231 Update Node.js to 16 2021-05-12 22:21:56 -07:00
Jason Schrader a33b48c9fe Update README.md release version
This change updates the release version for cloudflare/wrangler-action in all examples from `1.2.0` to `1.3.0`.

It also corrects a typo on the last example changing `TOML` to `YAML` based on the code below it.
2020-11-13 07:56:23 -07:00
Kristian Freeman 60c377d0bf Merge pull request #42 from Indigenuity/master
Suggest workflow_dispatch for manual deploys
2020-09-16 12:46:23 -05:00
Kristian Freeman 39c3d279a1 Merge pull request #43 from chromy/patch-1
Update Readme to reference v1.3.0
2020-09-16 12:45:29 -05:00
Hector Dearman 8df5ab90b3 Update Readme to reference v1.3.0
The readme mentions v1.2.0 but some of the commands (for example publish)
are only present in v1.3.0. Update readme to use v1.3.0 instead.
2020-09-11 22:05:51 +01:00
JD Kemsley f4e53e2753 Suggest workflow_dispatch for manual deploys 2020-09-11 12:53:43 -05:00
Kristian Freeman 3424d15af2 Merge pull request #35 from bradyjoslin/pre-post-commands
Add support for running pre and post commands
2020-08-21 11:31:16 -05:00
Brady Joslin 212d5a5125 eval the input command 2020-08-13 00:12:47 -05:00
Joslin, Brady W (Brady) bc7b76075d update explanation of publish option 2020-08-11 22:53:34 -05:00
Joslin, Brady W (Brady) 176cda2c0e add ability to skip publish 2020-08-11 22:46:42 -05:00
Joslin, Brady W (Brady) 93b9408aec pre-post-commands 2020-08-07 16:36:37 -05:00
Avery Harnish 6531840e6e Merge pull request #32 from jbampton/fix-word-case
Fix word case
2020-07-02 10:07:55 -05:00
John Bampton f871e6782e Fix word case 2020-07-02 17:17:05 +10:00
Kristian Freeman aab79315b4 Merge pull request #30 from bradyjoslin/patch-1
update secrets example in readme
2020-06-29 09:29:28 -05:00
Brady Joslin c511ea2eb5 Update README.md 2020-06-27 10:38:37 -05:00
Kristian Freeman 21f14faa06 Bump version in README 2020-06-22 10:32:48 -05:00
Kristian Freeman e5fc9a726a Merge pull request #28 from bradyjoslin/master
add secrets publishing
2020-06-22 10:27:18 -05:00
Brady Joslin 4259a86a6b Update deploy.yml 2020-06-22 10:02:00 -05:00
Joslin, Brady W (Brady) aabd478947 update test worker for testing secrets 2020-06-22 09:35:46 -05:00
Joslin, Brady W (Brady) 3123fc538b add secrets publishing 2020-06-15 23:09:55 -05:00
Jason Gill 1202bb2fe9 Remove nvm to speed build time
The Dockerfile already pulls the node:12 image, so there's no need for NVM to be downloaded and installed as well. Removing this speeds up the image build time (making Github Actions go faster)
2020-05-05 13:31:27 -05:00
Kristian Freeman e5160f5528 Merge pull request #14 from cloudflare/kristian/workflow
re-add GitHub Actions workflow
2020-05-05 13:01:29 -05:00
Kristian Freeman 1e37135bae Update workflow and separate into multiple jobs 2020-05-05 12:52:41 -05:00
Kristian Freeman 1c9291f9bf Merge pull request #23 from mscoutermarsh/patch-1
Improvements to the readme
2020-04-06 10:59:14 -05:00
Mike Coutermarsh 8dd9410702 Improvements to the readme
Setting checkout to V2 and fixing the environment link
2020-04-04 20:57:36 -07:00
Kristian Freeman 844c30604b Add workflow 2019-12-13 15:29:17 -06:00
Kristian Freeman 312aaaeeaa Merge pull request #11 from cloudflare/1.1.0
📡 1.1.0
2019-12-09 12:37:26 -06:00
Kristian Freeman 1827c33732 Temporarily disable GitHub Actions in this repo 2019-12-09 12:37:08 -06:00
Kristian Freeman 9e7e2ec6db It's wrangler-action 1.1.0! 📡
- Support `apiToken` as an authentication method
  - Deprecates `apiKey` and `email`, making them optional parameters and encouraging `apiToken` usage in build logs
- Support `wranglerVersion` for installing a specific Wrangler version for your build
- Per #7, support for `workingDirectory` to run `wrangler-action` in a specific directory in your repo
- Adds a test Workers project under the `test` directory. This is used in the repo's new set of workflows (see below)
- Adds a GitHub Action workflow that:
  - Lints `entrypoint.sh` to ensure that the shell script looks correct
  - Runs the action with various config options to ensure future pushes don't introduce regressions
2019-12-09 11:13:30 -06:00
Kristian Freeman 2360296525 Merge pull request #7 from replicatedhq/workingdir
Add workingDirectory option for publishing a subdirectory
2019-11-22 10:40:19 -06:00
Frank Shotwell bc0254d9f8 Add workingDirectory option for publishing a subdirectory 2019-11-07 13:15:49 -08:00
Kristian Freeman 05e5e7ad0d Merge pull request #2 from adaptive/patch-1
changed secrets naming
2019-10-30 10:03:53 -05:00
Hugo Romano 6b4d853121 naming convention to CF_ 2019-10-27 19:48:39 +00:00
Hugo Romano b190740662 changed secrets naming 2019-10-27 01:37:10 +01:00
Kristian Freeman 8da7fa65b4 Merge pull request #1 from adamschwartz/patch-1
Recommend adding `name` to action
2019-10-25 11:39:57 -05:00
Adam Schwartz d5240e236f recommend adding name to action 2019-10-24 18:31:04 -04:00
7 changed files with 3097 additions and 438 deletions
-5
View File
@@ -1,5 +0,0 @@
FROM node:12
ENV XDG_CONFIG_HOME /github/workspace
ENV WRANGLER_HOME /github/workspace
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
-176
View File
@@ -1,176 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
-25
View File
@@ -1,25 +0,0 @@
Copyright (c) 2019 Kristian Freeman <kristian@kristianfreeman.com>
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-180
View File
@@ -1,180 +0,0 @@
# Wrangler GitHub Action
✨ Zero-config [Cloudflare Workers](https://workers.cloudflare.com) deployment using [Wrangler](https://github.com/cloudflare/wrangler) and [GitHub Actions](https://github.com/actions)
## Usage
Add `wrangler-action` to the workflow for your Workers application. The below example will publish your application on pushes to the `master` branch:
```yaml
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@master
- name: Publish
uses: cloudflare/wrangler-action@1.0.0
with:
apiKey: ${{ secrets.apiKey }}
email: ${{ secrets.email }}
```
## Configuration
You'll need to configure Wrangler using GitHub's Secrets feature - go to "Settings -> Secrets" and add your Cloudflare API key and email (for help finding these, see the [Workers documentation](https://developers.cloudflare.com/workers/quickstart/#finding-your-cloudflare-api-keys)). Your API key and email are encrypted by GitHub, and the action won't print them into logs, so they should be safe!
With your API key and email set as secrets for your repository, pass them to the action in the `with` block of your workflow. Below, I've set the secret names to `apiKey` and `email`:
```yaml
jobs:
deploy:
name: Deploy
steps:
uses: cloudflare/wrangler-action@1.0.0
with:
apiKey: ${{ secrets.apiKey }}
email: ${{ secrets.email }}
```
Optionally, you can also pass an `environment` key to the action. If you're using Wrangler's [environments](https://github.com/cloudflare/wrangler/blob/master/docs/content/environments.md) feature, you can customize _where_ the action deploys to by passing the matching environment in the `with` block of your workflow:
```yaml
jobs:
deploy:
# ... previous configuration ...
steps:
uses: cloudflare/wrangler-action@1.0.0
with:
# ... api key and email ...
environment: 'production'
```
## Use cases
### Deploying when commits are merged to master
The above workflow examples have already shown how to run `wrangler-action` when new commits are merged to the master branch. For most developers, this workflow will easily replace manual deploys and be a great first integration step with `wrangler-action`:
```yaml
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@master
- name: Publish
uses: cloudflare/wrangler-action@1.0.0
with:
apiKey: ${{ secrets.apiKey }}
email: ${{ secrets.email }}
```
Note that there are a number of possible events, like `push`, that can be used to trigger a workflow. For more details on the events available, check out the [GitHub Actions documentation](https://help.github.com/en/articles/workflow-syntax-for-github-actions#on).
### Deploying on a schedule
If you'd like to deploy your Workers application on a recurring basis for instance, every hour, or daily the `schedule` trigger allows you to use cron syntax to define a workflow schedule. The below example will deploy at the beginning of every hour:
```yaml
on:
schedule:
- cron: '0 * * * *'
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@master
- name: Publish app
uses: cloudflare/wrangler-action@1.0.0
with:
apiKey: ${{ secrets.apiKey }}
email: ${{ secrets.email }}
```
If you need help defining the correct cron syntax, check out [crontab.guru](https://crontab.guru/), which provides a friendly user interface for validating your cron schedule.
### Deploying on a "dispatched" event
If you need to trigger a deployment at-will, you can use GitHub's API to fire a `repository_dispatch` event on your repository. By setting your workflow to trigger on that event, you'll be able to deploy your application via an API call:
```yaml
on:
repository_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@master
- name: Publish app
uses: cloudflare/wrangler-action@1.0.0
with:
apiKey: ${{ secrets.apiKey }}
email: ${{ secrets.email }}
```
To make the GitHub API request, you can deploy a custom [Cloudflare Workers](https://workers.cloudflare.com) function, which will send a `POST` request to GitHub's API and trigger a new deploy:
```js
const headers = {
Accept: 'application/vnd.github.everest-preview+json',
Authorization: 'Bearer $token',
}
const body = JSON.stringify({ event_type: 'repository_dispatch' })
const url = `https://api.github.com/repos/$owner/$repo/dispatches`
const handleRequest = async evt => {
await fetch(url, { method: 'POST', headers, body })
return new Response('OK')
}
addEventListener('fetch', handleRequest)
```
Note that `$token` in this code sample is a GitHub "Personal Access Token". For information on how to generate this token, see the [GitHub documentation on "repository_dispatch"](https://developer.github.com/v3/repos/#create-a-repository-dispatch-event).
## Troubleshooting
This action is in beta, and I'm looking for folks to use it! If something goes wrong, please file an issue! That being said, there's a couple things you should know:
### "I just started using Workers/Wrangler and I don't know what this is!"
No problem! Check out the [Quick Start guide](https://developers.cloudflare.com/workers/quickstart) in our docs to get started. Once you have a Workers application, you may want to set it up to automatically deploy from GitHub whenever you change your project. That's where this action comes in - nice!
### "I'm trying to deploy my static site but it isn't working!"
To deploy static sites and frontend applications to Workers, check out the documentation for [Workers Sites](https://developers.cloudflare.com/workers/sites).
Note that this action makes no assumptions about _how_ your project is built! **If you need to run a pre-publish step, like building your application, you need to specify a build step in your Workflow.** For instance, if I have an NPM command called `build`, my workflow TOML might resemble the following:
```yaml
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@master
- name: Build site
run: 'npm run build'
- name: Publish
uses: cloudflare/wrangler-action@1.0.0
with:
apiKey: ${{ secrets.apiKey }}
email: ${{ secrets.email }}
```
+35 -13
View File
@@ -1,17 +1,39 @@
name: 'Deploy to Cloudflare Workers with Wrangler'
name: "Deploy to Cloudflare Workers with Wrangler"
branding:
icon: 'upload-cloud'
color: 'orange'
description: 'Deploy your Cloudflare Workers applications and sites directly from GitHub, using Wrangler'
icon: "upload-cloud"
color: "orange"
description: "Deploy your Cloudflare projects from GitHub using Wrangler"
runs:
using: 'docker'
image: 'Dockerfile'
using: "node16"
main: "dist/index.mjs"
inputs:
apiKey:
description: "Your Cloudflare API Key"
required: true
email:
description: "Your Cloudflare Email"
required: true
apiToken:
description: "Your Cloudflare API Token"
required: false
accountId:
description: "Your Cloudflare Account ID"
required: false
environment:
description: "The environment you'd like to publish your Workers project to - must be defined in wrangler.toml"
description: "The environment you'd like to deploy your Workers project to - must be defined in wrangler.toml"
workingDirectory:
description: "The relative path which Wrangler commands should be run from"
required: false
wranglerVersion:
description: "The version of Wrangler you'd like to use to deploy your Workers project"
required: false
secrets:
description: "A string of environment variable names, separated by newlines. These will be bound to your Worker as Secrets and must match the names of environment variables declared in `env` of this workflow."
required: false
preCommands:
description: "Commands to execute before deploying the Workers project"
required: false
postCommands:
description: "Commands to execute after deploying the Workers project"
required: false
command:
description: 'The Wrangler command (along with any arguments) you wish to run. Multiple Wrangler commands can be run by separating each command with a newline. Defaults to `"deploy"`.'
required: false
vars:
description: "A string of environment variable names, separated by newlines. These will be bound to your Worker using the values of matching environment variables declared in `env` of this workflow."
required: false
+3062
View File
File diff suppressed because it is too large Load Diff
-39
View File
@@ -1,39 +0,0 @@
#!/bin/sh
set -e
export HOME="/github/workspace"
export NVM_DIR="/github/workspace/nvm"
export WRANGLER_HOME="/github/workspace"
# h/t https://github.com/elgohr/Publish-Docker-Github-Action
sanitize() {
if [ -z "${1}" ]
then
>&2 echo "Unable to find ${2}. Did you add a GitHub secret called key ${2}, and pass in secrets.${2} in your workflow?"
exit 1
fi
}
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
mkdir -p "$HOME/.wrangler"
chmod -R 770 "$HOME/.wrangler"
sanitize "${INPUT_EMAIL}" "email"
sanitize "${INPUT_APIKEY}" "apiKey"
export CF_EMAIL="$INPUT_EMAIL"
export CF_API_KEY="$INPUT_APIKEY"
npm i @cloudflare/wrangler -g
if [ -z "$INPUT_ENVIRONMENT" ]
then
wrangler publish
else
wrangler publish -e "$INPUT_ENVIRONMENT"
fi