Skip to content

Commit

Permalink
ci: add deployment workflow for GitHub Actions
Browse files Browse the repository at this point in the history
This commit introduces a new GitHub Actions workflow, deploy.yml, for automating deployment to Workers whenever a release is pre-released or released. The workflow includes steps for fetching sources, caching cargo dependencies, installing the stable toolchain and worker-build, building with worker-build, and deploying to Workers. The concurrency setting ensures only one workflow runs at any given time per branch to prevent conflicts.
  • Loading branch information
nekofar committed Sep 21, 2023
1 parent dcb8357 commit da434f8
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Deploy & Publish
on:
release:
types: [ prereleased, released ]

jobs:

# Prepare and publish
deploy:
name: Deploy to Workers
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3.6.0
with:
ref: ${{ github.event.release.tag_name }}

# Cache dependencies to speed up builds
- name: Cache cargo dependencies
uses: actions/cache@v3.3.2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install stable toolchain
uses: actions-rs/toolchain@v1.0.6
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true

- name: Install worker-build
uses: actions-rs/cargo@v1.0.1
with:
command: install
args: worker-build

- name: Build by worker-build
run: worker-build

- name: Deploy to Workers
uses: cloudflare/wrangler-action@v3.1.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

0 comments on commit da434f8

Please sign in to comment.