├── .gitignore ├── LICENSE ├── action.yml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Neobrains 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Deta Space Deployment Github Action 2 | description: Github Action for deploying Deta Space apps. 3 | 4 | branding: 5 | icon: upload-cloud 6 | color: purple 7 | 8 | inputs: 9 | access_token: 10 | description: Deta access token for Deta Space CLI authentication. 11 | required: true 12 | 13 | project_id: 14 | description: Deta Space app project ID. 15 | required: true 16 | 17 | project_directory: 18 | description: Directory of the Deta Space project. 19 | required: false 20 | default: "." 21 | 22 | space_push: 23 | description: Whether to do space push. Valid value is "true". Space push will not be performed by default. 24 | required: false 25 | default: false 26 | 27 | experimental: 28 | description: Whether to use the experimental runner version for space push. Valid value is "true". 29 | required: false 30 | default: false 31 | 32 | space_release: 33 | 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. 34 | required: false 35 | default: false 36 | 37 | list_on_discovery: 38 | description: Whether to list the latest revision on Space Discovery. Valid value is "true". Listing on Space Discovery will not be performed by default. 39 | required: false 40 | default: false 41 | 42 | release_version: 43 | description: Version for the release. If not provided, Deta Space will generate a version by default. 44 | required: false 45 | 46 | runs: 47 | using: composite 48 | 49 | steps: 50 | - name: Install Deta Space CLI & set SPACE_ACCESS_TOKEN environment variable 51 | shell: bash 52 | run: | 53 | curl -fsSL https://get.deta.dev/space-cli.sh | sh 54 | echo "$HOME/.detaspace/bin" >> $GITHUB_PATH 55 | echo "SPACE_ACCESS_TOKEN=${{ inputs.access_token }}" >> $GITHUB_ENV 56 | 57 | - name: Push changes to Deta Space 58 | if: ${{ inputs.space_push == 'true' }} 59 | shell: bash 60 | run: | 61 | cd ${{ inputs.project_directory }} 62 | space link --id "${{ inputs.project_id }}" 63 | if [[ ${{ inputs.experimental }} == true ]]; then 64 | space push --runner-version experimental 65 | else 66 | space push 67 | fi 68 | 69 | - name: Create a release on Deta Space 70 | if: ${{ inputs.space_release == 'true' }} 71 | shell: bash 72 | run: | 73 | cd ${{ inputs.project_directory }} 74 | space link --id "${{ inputs.project_id }}" 75 | if [[ ${{ inputs.list_on_discovery }} == true ]]; then 76 | space release --version "${{ inputs.release_version }}" --listed --confirm 77 | else 78 | space release --version "${{ inputs.release_version }}" --confirm 79 | fi 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Space Pipe 2 | 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. 3 | 4 | Thanks for the help ✨ [Sponge](https://github.com/rohanshiva). 5 | 6 | ## Usage 7 | - Push your changes to create a new revision of your app. 8 | - 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). 9 | 10 | ## Inputs 11 | - `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*. 12 | 13 | - `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*. 14 | 15 | - `project_directory` : (Optional) The directory where your project is located. The default value is the root directory. 16 | 17 | - `space_push` : (Optional) If true, pushes your changes to Space and creates a new revision. The default value is false. 18 | 19 | - `experimental` : (Optional) If true, uses Deta Space's experimental runner. The default value is false. 20 | 21 | - `space_release` : (Optional) If true, the latest revision will be released to Space. The default value is false. 22 | 23 | - `list_on_discovery` : (Optional) If true, the latest revision will be listed on Space Discovery. The default value is false. 24 | 25 | - `release_version` : (Optional) Version for the release. If not provided, Deta Space will generate a version by default. 26 | 27 |
28 | 29 | ⚠️ Neither **list_on_discovery** nor **release_version** can be used without **space_release** set to "true" as both of them are optional args of **space_release**. 30 | 31 | ⚠️ Use [GitHub Actions secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) to store your inputs. 32 | 33 | ⚠️ 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. 34 | 35 | ## Example workflow 36 | ``` 37 | name: Push to Space 38 | on: push 39 | 40 | jobs: 41 | push-to-space: 42 | runs-on: ubuntu-latest 43 | steps: 44 | - uses: actions/checkout@v3 45 | - name: Deta Space Deployment Github Action 46 | uses: neobrains/space-pipe@v0.5 47 | with: 48 | access_token: ${{ secrets.ACCESS_TOKEN }} 49 | project_id: ${{ secrets.PROJECT_ID }} 50 | space_push: true 51 | list_on_discovery: true 52 | ``` 53 | 54 | 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**. 55 | 56 | ### Some workflow examples to manage your deployments: 57 | - 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. 58 | - 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. 59 | 60 | - 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. 61 | 62 | ## License 63 | 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). 64 | --------------------------------------------------------------------------------