├── README.md └── action.yml /README.md: -------------------------------------------------------------------------------- 1 | # Shuttle Deploy Action 2 | 3 | This action automates the deployment of a Rust project to [Shuttle](https://www.shuttle.dev/). This action deploys the project to Shuttle, which builds it and hosts it. 4 | 5 | Note that you need to have created a project on Shuttle before you can deploy to it. Provide the project ID in the inputs. 6 | 7 | **Shuttle Secrets** are saved from previous deployments. Therefore, they are usually not be needed in your CD pipeline. 8 | The choice is yours, whether you prefer to add **Shuttle Secrets** with a manual deployment, or in a continuous way using the `secrets` input of this action. 9 | Read more about **Shuttle Secrets** [here](https://docs.shuttle.dev/resources/shuttle-secrets). 10 | 11 | ## Inputs 12 | 13 | | Name | Description | Required | Default | 14 | |-----------------------| --- | --- | --- | 15 | | shuttle-api-key | The Shuttle API key | true | N/A | 16 | | project-id | Project ID, starts with `proj_` | true | N/A | 17 | | cargo-shuttle-version | Version of cargo-shuttle | false | `""` (latest) | 18 | | working-directory | The cargo workspace root | false | `"."` | 19 | | secrets | Content of the `Secrets.toml` file, if any | false | `""` | 20 | | extra-args | Extra args to the deploy command | false | `""` | 21 | 22 | ## Outputs 23 | 24 | | Name | Description | 25 | | --- | --- | 26 | 27 | 28 | ## Example usage 29 | 30 | ### Typical Example 31 | 32 | ```yaml 33 | name: Shuttle Deploy 34 | 35 | on: 36 | push: 37 | branches: 38 | - main 39 | workflow_dispatch: 40 | 41 | jobs: 42 | deploy: 43 | runs-on: ubuntu-latest 44 | steps: 45 | - uses: shuttle-hq/deploy-action@v2 46 | with: 47 | shuttle-api-key: ${{ secrets.SHUTTLE_API_KEY }} 48 | project-id: proj_0123456789 49 | ``` 50 | 51 | ### Example with all inputs 52 | 53 | ```yaml 54 | name: Shuttle Deploy 55 | 56 | on: 57 | push: 58 | branches: 59 | - main 60 | workflow_dispatch: 61 | 62 | jobs: 63 | deploy: 64 | runs-on: ubuntu-latest 65 | steps: 66 | - uses: shuttle-hq/deploy-action@v2 67 | with: 68 | shuttle-api-key: ${{ secrets.SHUTTLE_API_KEY }} 69 | project-id: proj_0123456789 70 | working-directory: "backend" 71 | cargo-shuttle-version: "0.48.1" 72 | extra-args: --allow-dirty --debug 73 | secrets: | 74 | MY_AWESOME_SECRET_1 = '${{ secrets.SECRET_1 }}' 75 | MY_AWESOME_SECRET_2 = '${{ secrets.SECRET_2 }}' 76 | ``` 77 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Shuttle Deploy 2 | description: Deploy to Shuttle 3 | 4 | inputs: 5 | shuttle-api-key: 6 | description: The key found at https://console.shuttle.dev/account/overview 7 | required: true 8 | cargo-shuttle-version: 9 | description: Version of cargo-shuttle 10 | required: false 11 | default: "" 12 | working-directory: 13 | description: The cargo workspace root 14 | required: false 15 | default: . 16 | project-id: 17 | description: Project ID 18 | required: true 19 | secrets: 20 | description: | 21 | Content of the `Secrets.toml` file, if any. 22 | Use multiline text with `|` in case of multiple secrets 23 | required: false 24 | default: "" 25 | extra-args: 26 | description: Extra args to the deploy command 27 | required: false 28 | default: "" 29 | 30 | runs: 31 | using: "composite" 32 | steps: 33 | # check out repo if not done already 34 | - id: check-repo-is-not-initialized 35 | run: echo "remote-url=$( git config --get remote.origin.url )" >> $GITHUB_OUTPUT 36 | shell: bash 37 | - uses: actions/checkout@v4 38 | if: ${{ !contains(steps.check-repo-is-not-initialized.outputs.remote-url, github.repository) }} 39 | 40 | # install with cargo-binstall 41 | - name: Install cargo-binstall 42 | run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash 43 | shell: bash 44 | - name: Install cargo-shuttle 45 | if: ${{ inputs.cargo-shuttle-version == '' }} 46 | run: cargo binstall -y --locked cargo-shuttle 47 | shell: bash 48 | - name: Install cargo-shuttle ${{ inputs.cargo-shuttle-version }} 49 | if: ${{ inputs.cargo-shuttle-version != '' }} 50 | run: cargo binstall -y --locked cargo-shuttle@${{ inputs.cargo-shuttle-version }} 51 | shell: bash 52 | 53 | - name: Create secret file 54 | if: ${{ inputs.secrets != '' }} 55 | run: echo "${{ inputs.secrets }}" > Secrets.toml 56 | working-directory: ${{ inputs.working-directory }} 57 | shell: bash 58 | 59 | - name: Deploy to Shuttle 60 | run: shuttle deploy --id ${{ inputs.project-id }} ${{ inputs.extra-args }} 61 | working-directory: ${{ inputs.working-directory }} 62 | env: 63 | SHUTTLE_API_KEY: ${{ inputs.shuttle-api-key }} 64 | shell: bash 65 | --------------------------------------------------------------------------------