Compare commits
239 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a84dcc6dd3 | |||
| ea5754c9ad | |||
| 983b6349c2 | |||
| b05934f581 | |||
| 31a6263ef3 | |||
| 88906781f0 | |||
| ebef541795 | |||
| 9d4ca0f255 | |||
| 1be73b90f6 | |||
| 180648017b | |||
| 9003b06015 | |||
| fd98a7c990 | |||
| 4bf3047bb8 | |||
| f2c22accd3 | |||
| 0c36639f72 | |||
| d5a1abb013 | |||
| c214b69bae | |||
| bac2829d42 | |||
| 78c994fb95 | |||
| e3434a7e98 | |||
| 08514fdece | |||
| 7451182d38 | |||
| 522c117b7d | |||
| b92719544e | |||
| bbedd8e54f | |||
| ebaf896045 | |||
| 7e684fbad9 | |||
| 2521ec00cc | |||
| ba0f485178 | |||
| 2de0b3dfd8 | |||
| f2d9b652c4 | |||
| 0e62acaf21 | |||
| bd3857047e | |||
| d13856dfc9 | |||
| f88aee4953 | |||
| a5f361f3f0 | |||
| 9aba9c34da | |||
| 9dd38ad790 | |||
| 1599928d8e | |||
| 0fff39f4b7 | |||
| ca0bf5eeba | |||
| 97c920b38e | |||
| 11fa60953d | |||
| 5ee7b681bc | |||
| 74a612d924 | |||
| 0558fc8c04 | |||
| 976ec4d78c | |||
| a8845f6d95 | |||
| 8d6fade5ad | |||
| 65996a5230 | |||
| 2b7ed1316d | |||
| 9554b3575b | |||
| 57159ca2ed | |||
| 7dd5c3621b | |||
| 581e17bc51 | |||
| 21a8414ba3 | |||
| 819ea006e6 | |||
| 473d9cbd29 | |||
| 76d614f400 | |||
| d647227bbc | |||
| 533097350a | |||
| bc7253f187 | |||
| b2e459a047 | |||
| 96c3774b77 | |||
| b00f94ea6f | |||
| c649733249 | |||
| d43f9c81c7 | |||
| 219a0887d7 | |||
| 25b114f472 | |||
| f40a9f5f82 | |||
| bd06b290b1 | |||
| a4509d507c | |||
| 0e6f0d3080 | |||
| 326ba30882 | |||
| 032a7248fa | |||
| 080373bdb6 | |||
| 231d787db1 | |||
| d9a0a00f8b | |||
| 779191a652 | |||
| 556068fb59 | |||
| caa59485d0 | |||
| c2494c1ca6 | |||
| 528687aaf4 | |||
| bd50d10af9 | |||
| 2513ffc6cc | |||
| 9df50d42e4 | |||
| 4611c14c05 | |||
| ac3f259fcf | |||
| b2645622e9 | |||
| f4e6269765 | |||
| 72931e59b2 | |||
| e0254d06bc | |||
| 13d70757d2 | |||
| aec73ae744 | |||
| f0cc3efccf | |||
| 50b529e7b8 | |||
| 6771675815 | |||
| 4ae0557f8d | |||
| 7d7b98826e | |||
| d1073d57ba | |||
| c3b99e2c18 | |||
| 2375787b23 | |||
| 11f981cea4 | |||
| 868dbd9a40 | |||
| a009342d77 | |||
| f2e4cda4dd | |||
| f4f2e854d7 | |||
| cbe5f5b523 | |||
| fcf2d83f3d | |||
| f5d1ca36ae | |||
| 4d6d6abfb4 | |||
| 416205365a | |||
| 7292a4ae99 | |||
| 4528b66125 | |||
| ee3e2a9b37 | |||
| 361844799a | |||
| 26103fa86c | |||
| 47d4afdbd8 | |||
| d7637bf514 | |||
| 71199d2757 | |||
| 2962e94ac8 | |||
| 5517edbb28 | |||
| f74c325efc | |||
| 105f191b19 | |||
| e5251df521 | |||
| b076e889fb | |||
| 30e126d1a4 | |||
| fcf648c789 | |||
| fcbabec21e | |||
| 0aa12f0c2b | |||
| ad7441b6ad | |||
| 3f40637a1c | |||
| 4132892387 | |||
| 62ce9d23a3 | |||
| f089b0a195 | |||
| 4318a2fb97 | |||
| c8bbc2b667 | |||
| 3c262de2e3 | |||
| 36ba30dcc9 | |||
| a9ac89cd00 | |||
| 93b26a6664 | |||
| 9641d961b5 | |||
| 5b3d60c156 | |||
| 3252711404 | |||
| 2faabf36a2 | |||
| b734d85d74 | |||
| 8ca2ff1612 | |||
| 7d08a8657e | |||
| e193627f19 | |||
| 55b80c5f62 | |||
| f61dc4d5a9 | |||
| 58f274b9f7 | |||
| ef7686b259 | |||
| d63b9dc486 | |||
| 88ccce72e0 | |||
| 554eea134a | |||
| a584cc5606 | |||
| 0f5076c3e7 | |||
| c7d1bd35bf | |||
| 3c728e1d5d | |||
| a333df3c9e | |||
| bb0133dcfc | |||
| 88466ea5ae | |||
| 74433eb31e | |||
| 559dd40fe6 | |||
| 9930080b73 | |||
| 43bbbb16ab | |||
| 598c6b4043 | |||
| 0c094f5307 | |||
| 6ea2e616f2 | |||
| 1b4a61cee9 | |||
| 8e3876a0c9 | |||
| 8fab856f8d | |||
| ce1ea4e7c3 | |||
| e420d29d0a | |||
| 311d514d9d | |||
| d05a65f82b | |||
| c9da75b82e | |||
| 29cef5effc | |||
| ee60b7bd5e | |||
| 0ab3500d54 | |||
| dfa59a861f | |||
| 342e6243b7 | |||
| d6590f86f4 | |||
| 97e54f3396 | |||
| f85e1acfa7 | |||
| e18e1dfc82 | |||
| 20ea506049 | |||
| 45c57ae013 | |||
| a5fd4fdd34 | |||
| 002bb083fa | |||
| 42c609b2d6 | |||
| c8f756bccf | |||
| 81fb6a9681 | |||
| 6231e31709 | |||
| 0c419bee6c | |||
| 74a9b9885f | |||
| 3dd57ff2bb | |||
| edb2a58814 | |||
| 4c10c1822a | |||
| 3d1979ca8e | |||
| 6f62debcf8 | |||
| 006366c1ae | |||
| 95ac136231 | |||
| a33b48c9fe | |||
| 60c377d0bf | |||
| 39c3d279a1 | |||
| 8df5ab90b3 | |||
| f4e53e2753 | |||
| 3424d15af2 | |||
| 212d5a5125 | |||
| bc7b76075d | |||
| 176cda2c0e | |||
| 93b9408aec | |||
| 6531840e6e | |||
| f871e6782e | |||
| aab79315b4 | |||
| c511ea2eb5 | |||
| 21f14faa06 | |||
| e5fc9a726a | |||
| 4259a86a6b | |||
| aabd478947 | |||
| 3123fc538b | |||
| 1202bb2fe9 | |||
| e5160f5528 | |||
| 1e37135bae | |||
| 1c9291f9bf | |||
| 8dd9410702 | |||
| 844c30604b | |||
| 312aaaeeaa | |||
| 1827c33732 | |||
| 9e7e2ec6db | |||
| 2360296525 | |||
| bc0254d9f8 | |||
| 05e5e7ad0d | |||
| 6b4d853121 | |||
| b190740662 | |||
| 8da7fa65b4 | |||
| d5240e236f |
@@ -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
@@ -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
@@ -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.
|
||||
@@ -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 }}
|
||||
```
|
||||
+49
-13
@@ -1,17 +1,53 @@
|
||||
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'
|
||||
# Possible values: https://github.com/actions/runner/blob/main/src/Runner.Common/Util/NodeUtil.cs#L9
|
||||
using: "node20"
|
||||
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
|
||||
quiet:
|
||||
description: "Supresses output from Wrangler commands, defaults to `false`"
|
||||
required: false
|
||||
default: "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
|
||||
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
|
||||
outputs:
|
||||
command-output:
|
||||
description: "The output of the Wrangler command (comes from stdout)"
|
||||
command-stderr:
|
||||
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"
|
||||
|
||||
Vendored
+28755
File diff suppressed because one or more lines are too long
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user