Skip to content

Commit

Permalink
preview deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Rajat Jindal <[email protected]>
  • Loading branch information
rajatjindal committed Mar 24, 2023
1 parent 912e691 commit 6d82f5b
Show file tree
Hide file tree
Showing 13 changed files with 33,207 additions and 245 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/e2e-spin-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: deploy spin app preview e2e tests
on:
pull_request:
branches: ["main"]
types: ['opened', 'synchronize', 'reopened', 'closed']

jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'fermyon' }}
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 19

- name: npm install
run: npm install

- name: npm run build
run: npm run package
env:
NODE_OPTIONS: --openssl-legacy-provider

- name: upload artifact
uses: actions/upload-artifact@v3
with:
name: spin-actions
path: dist/spin/preview/index.js

deploy-preview-fermyon-cloud:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Retrieve saved Github action
uses: actions/download-artifact@v3
with:
name: spin-actions
path: dist/spin/preview/

- name: setup spin
uses: ./spin/setup/
with:
version: canary
plugins: js2wasm
github_token: ${{ github.token }}

- name: build and deploy preview
uses: ./spin/preview/
with:
fermyon_token: ${{ secrets.FERMYON_CLOUD_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
manifest_file: example-app/spin.toml
undeploy: ${{ github.event.pull_request && github.event.action == 'closed' }}
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GitHub Actions for Fermyon/Spin: fermyon/actions
# GitHub Actions for Fermyon Cloud/Spin apps

The `fermyon/actions` is a collection of Github actions to enable running [spin](https://github.com/fermyon/spin) commands in your GitHub Actions workflow.

Expand All @@ -7,6 +7,7 @@ It enables the following usecases:
- setup spin and plugins (`fermyon/actions/spin/setup`)
- build and push to OCI registry (`fermyon/actions/spin/push`)
- deploy to Fermyon Cloud (`fermyon/actions/spin/deploy`)
- deploy PR preview to Fermyon Cloud (`fermyon/actions/spin/preview`)

## `fermyon/action/spin/setup`

Expand Down Expand Up @@ -179,3 +180,49 @@ jobs:
manifest_file: example-app/spin.toml
fermyon_token: ${{ secrets.FERMYON_CLOUD_TOKEN }}
```
## `fermyon/action/spin/preview`

Build and deploy the `spin` app preview to Fermyon Cloud

### Inputs

| Name | Required | Description | Default |
| ------------- | -------- | --------------------------------------------------------------------------------- | --------- |
| fermyon_token | Required | Fermyon Cloud Personal access token for deploying the `spin` app to Fermyon Cloud | - |
| manifest_file | Optional | Path to `spin.toml`. Used with the `build`/`deploy` command. | spin.toml |
| github_token | Required | The `GitHub` token for updating comment on PR | - |
| undeploy | Optional | If true, removes the preview deployment from Fermyon Cloud | - |

### Example

```yaml
name: spin
on:
pull_request:
branches: ["main", "v*"]
types: ['opened', 'synchronize', 'reopened', 'closed']
jobs:
spin:
runs-on: ubuntu-latest
name: Build and deploy
steps:
- uses: actions/checkout@v3
- name: Setup `spin`
uses: fermyon/actions/spin/setup@v1
with:
version: canary
plugins: js2wasm

- name: build and deploy
uses: fermyon/actions/spin/preview@v1
with:
manifest_file: example-app/spin.toml
fermyon_token: ${{ secrets.FERMYON_CLOUD_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
undeploy: ${{ github.event.pull_request && github.event.action == 'closed' }}
```
Loading

0 comments on commit 6d82f5b

Please sign in to comment.