Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from neobrains/space-release
Browse files Browse the repository at this point in the history
Add space release
  • Loading branch information
mikBighne98 authored Nov 22, 2022
2 parents a7fade9 + f46b4ce commit 1e901b1
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 17 deletions.
35 changes: 25 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
# Space Deployment Github Action
A simple GitHub Action to deploy your projects to [Deta Space](https://alpha.deta.space/) and let their [builder](https://alpha.deta.space/docs/en/basics/projects#projects-in-builder) build your apps.

Thanks for the help ✨ [Sponge](https://github.com/rohanshiva).

## Usage
GitHub Action to 🚀 push your project to [Deta Space](https://alpha.deta.space/).
- Push your changes to create a new revision of your app.
- Release your latest revision. Each release can either be unlisted, where only people with the link can install it, or listed, which makes a release available for anyone to discover and install with [Deta Discovery](https://alpha.deta.space/discovery).

## Inputs
- ### `access_token`
Used for Space CLI authentication. From [Deta Space Dashboard](https://alpha.deta.space), open the teletype (command bar) and click on `Settings`. In the settings modal, click on `Generate Token` to generate an access token and copy the resulting token.
- `access_token` : Used for Space CLI authentication. From [Deta Space Dashboard](https://alpha.deta.space), open the *teletype* (command bar) and click on *Settings*. In the settings modal, click on *Generate Token* to generate an access token and copy the resulting *access token*.

- ### `project_id`
Used for getting the .space folder for pushing your code to Deta Space. To get your project id go to the [Builder](https://alpha.deta.space/builder) and in your project’s `Develop` tab, open the teletype (command bar) and copy the Project ID.
- `project_id` : Used for getting the *.space folder* for pushing your code to Deta Space. To get your project id go to the [Builder](https://alpha.deta.space/builder) and in your project’s *Develop* tab, open the *teletype* (command bar) and copy the *Project ID*.

- `space_push` : (Optional) If true, pushes your changes to Space and creates a new revision. The default value is false.

- `space_release` : (Optional) If true, the latest revision will be released to Space. The default value is false.

- `list_on_discovery` : (Optional) If true, the latest revision will be released to Space & listed on Space Discovery. The default value is false.<br> 📌 No need to use *space_release* with this.

<br>

<br/><br/>
⚠️ Use [GitHub Actions secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) to store your inputs.

⚠️ Make sure to add your 📝 [Spacefile](https://alpha.deta.space/docs/en/reference/spacefile) in your repository. It contains the configuration of your project and is used by Deta Space to understand what your project looks like and how to run it.
⚠️ Make sure to add your 📝[Spacefile](https://alpha.deta.space/docs/en/reference/spacefile) in your repository. It contains the configuration of your project and is used by Deta Space to understand what your project looks like and how to run it.

## Example workflow
```
Expand All @@ -32,9 +39,17 @@ jobs:
with:
access_token: ${{ secrets.ACCESS_TOKEN }}
project_id: ${{ secrets.PROJECT_ID }}
space_push: true
list_on_discovery: true
```

Here [access_token](#access_token) and [project_id](#project_id) are stored as ACCESS_TOKEN and PROJECT_ID in GitHub Actions secrets.
<br/>
Here [access_token](#access_token) and [project_id](#project_id) are stored as *ACCESS_TOKEN* and *PROJECT_ID* in GitHub Actions secrets. After creating a new revision with *space_push*, the latest revision will be listed on Space Discovery with *list_on_discovery*.

### Some workflow examples to manage your deployments:
- A single workflow can be created with [jobs](https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs) to do space push, release of that revision and list that on Space Discovery with conditions to run a subsequent job if the previous one was successful.
- A workflow with *space_push* can be set up to run on [each push to the workflow's repository](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push). Separate workflows for *space_release* and *list_on_discovery* can be set up to run on [workflow_dispatch](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch) to be executed when needed.

- Configure your workflow to do *space_push* on each push to devlopment branch, *space_release* on each push to test branch and *list_on_discovery* on each push to main or master branch.

💬 The [Space CLI](https://alpha.deta.space/docs/en/reference/cli) needs standard inputs for creating releases. ***As of now*** this feature is not implemented in this GitHub Action. Follow the instructions [here](https://alpha.deta.space/docs/en/basics/releases#releasing-from-the-gui) to create a release for your project.
## License
This GitHub Action and associated documentation in this project are released under the [MIT License](https://github.com/neobrains/space-deployment-github-action/blob/master/LICENSE).
43 changes: 36 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 'Deta Space Deployment Github Action'
description: 'Github Action for deploying Deta Space apps.'

branding:
icon: 'upload-cloud'
color: 'purple'
Expand All @@ -13,20 +14,48 @@ inputs:
description: 'Deta Space app project ID.'
required: true

space_push:
description: Whether to do space push. Valid value is "true". Space push will not be performed by default.
required: false

space_release:
description: Whether to do space release without listing the revision on Space Discovery. Valid value is "true". Space release will not be performed by default.
required: false

list_on_discovery:
description: Whether to do space release & list the latest revision on Space Discovery. Valid value is "true". Space release and listing on discovery will not be performed by default.
required: false

runs:
using: 'composite'

steps:
- name: 'Install Deta Space CLI & add access token'
- name: 'Install Deta Space CLI & set SPACE_ACCESS_TOKEN environment variable'
shell: bash
run: |
curl -fsSL https://get.deta.dev/space-cli.sh | sh
- name: 'Get .space folder and push'
shell: script -q -e -c "bash {0}"
env:
SPACE_ACCESS_TOKEN: ${{ inputs.access_token }}
echo '/home/runner/.detaspace/bin' >> $GITHUB_PATH
echo "SPACE_ACCESS_TOKEN=${{ inputs.access_token }}" >> $GITHUB_ENV
- name: 'Get .space folder'
shell: bash
run: |
export PATH="/home/runner/.detaspace/bin:$PATH"
space link -i ${{ inputs.project_id }}
- name: 'Push changes to Deta Space'
if: ${{ inputs.space_push == 'true' }}
shell: script -q -e -c "bash {0}"
run: |
space push
- name: 'Release latest revision'
if: ${{ inputs.space_release == 'true' }}
shell: script -q -e -c "bash {0}"
run: |
space release -c
- name: 'List latest release on Space Discovery'
if: ${{ inputs.list_on_discovery == 'true' }}
shell: script -q -e -c "bash {0}"
run: |
space release -l -c

0 comments on commit 1e901b1

Please sign in to comment.