├── Dockerfile ├── README.md ├── action.yml └── entrypoint.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | LABEL version="1.0.0" 4 | LABEL repository="https://github.com/convox/action-deploy" 5 | LABEL homepage="https://convox.com/convox" 6 | LABEL maintainer="Convox " 7 | 8 | LABEL "com.github.actions.name"="Convox Deploy" 9 | LABEL "com.github.actions.description"="Build and Deploy an app to Convox in one step" 10 | LABEL "com.github.actions.icon"="cloud" 11 | LABEL "com.github.actions.color"="blue" 12 | 13 | RUN apt-get -qq update && apt-get -qq -y install curl 14 | 15 | RUN curl -L https://github.com/convox/convox/releases/latest/download/convox-linux -o /tmp/convox \ 16 | && mv /tmp/convox /usr/local/bin/convox \ 17 | && chmod 755 /usr/local/bin/convox 18 | 19 | COPY entrypoint.sh /entrypoint.sh 20 | ENTRYPOINT ["/entrypoint.sh"] 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Convox Deploy Action 2 | If you [Install a Convox Rack](https://github.com/convox/installer) using the cloud provider of your choice and create a [convox.yml](https://docs.convox.com/application/convox-yml) to describe your application and its dependencies you can use this action to automatically [deploy](https://docs.convox.com/introduction/getting-started#deploy-your-application) your app. 3 | The Deploy action performs the functions of combining the [Build](https://github.com/convox/action-build) and [Promote](https://github.com/convox/action-promote) actions but in a single step. If you want to create more advanced workflows you can do so by using our [individual actions](#creating-more-advanced-workflows). 4 | 5 | ## Inputs 6 | ### `rack` 7 | **Required** The name of the [Convox Rack](https://docs.convox.com/introduction/rack) you wish to deploy to. 8 | ### `app` 9 | **Required** The name of the [app](https://docs.convox.com/deployment/creating-an-application) you wish to deploy to. 10 | ### `password` 11 | **Required** The value of your [Convox Deploy Key](https://docs.convox.com/console/deploy-keys) 12 | ### `host` 13 | **Optional** The host name of your [Convox Console](https://docs.convox.com/introduction/console). This defaults to `console.convox.com` and only needs to be overwritten if you have a [self-hosted console](https://docs.convox.com/reference/hipaa-compliance#run-a-private-convox-console) 14 | ### `cached` 15 | **Optional** Whether to utilise the docker cache during the build. Defaults to true. 16 | ### `manifest` 17 | **Optional** Use a custom path for your convox.yml 18 | ### `buildargs` 19 | **Optional** Pass docker build arguments to the build process. Build args are key-value pairs separated by a newline: 20 | ``` 21 | buildargs: | 22 | BASEIMAGE=myimage 23 | MYARG=hello 24 | ``` 25 | 26 | 27 | ## Example Usage 28 | ``` 29 | uses: convox/action-deploy@2.0.0 30 | with: 31 | rack: staging 32 | app: myapp 33 | password: ${{ secrets.CONVOX_DEPLOY_KEY }} 34 | ``` 35 | 36 | ## Creating More Advanced Workflows 37 | Convox provides a full set of Actions to enable a wide variety of deployment workflows. The following actions are available: 38 | ### [Login](https://github.com/convox/action-login) 39 | Authenticates your Convox account You should run this action as the first step in your workflow 40 | ### [Build](https://github.com/convox/action-build) 41 | Builds an app and creates a release which can be promoted later 42 | ### [Run](https://github.com/convox/action-run) 43 | Runs a command (such as a migration) using a previously built release before or after it is promoted 44 | ### [Promote](https://github.com/convox/action-promote) 45 | Promotes a release 46 | 47 | Example workflow building a Rails app and running migrations before deploying: 48 | ``` 49 | name: CD 50 | 51 | on: [push] 52 | 53 | jobs: 54 | build: 55 | runs-on: ubuntu-latest 56 | steps: 57 | - name: checkout 58 | id: checkout 59 | uses: actions/checkout@v1 60 | - name: login 61 | id:login 62 | uses: convox/action-login@v1 63 | with: 64 | password: ${{ secrets.CONVOX_DEPLOY_KEY }} 65 | - name: build 66 | id: build 67 | uses: convox/action-build@v1 68 | with: 69 | rack: staging 70 | app: myrailsapp 71 | - name: migrate 72 | id:migrate 73 | uses: convox/action-run@v1 74 | with: 75 | rack: staging 76 | app: myrailsapp 77 | service: web 78 | command: rake db:migrate 79 | release: ${{ steps.build.outputs.release }} 80 | - name: promote 81 | id: promote 82 | uses: convox/action-promote@v1 83 | with: 84 | rack: staging 85 | app: myrailsapp 86 | release: ${{ steps.build.outputs.release }} 87 | 88 | 89 | ``` 90 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Convox Deploy 2 | description: Build and Deploy a Convox app in a single step 3 | author: Convox 4 | branding: 5 | icon: upload-cloud 6 | color: blue 7 | inputs: 8 | rack: 9 | description: Convox Rack name 10 | required: true 11 | app: 12 | description: Convox app name 13 | required: true 14 | password: 15 | description: Convox deploy key value 16 | required: false 17 | host: 18 | description: Convox Console host address 19 | required: false 20 | default: console.convox.com 21 | description: 22 | description: Convox build description 23 | required: false 24 | cached: 25 | description: Whether to utilise the docker cache during the build 26 | required: false 27 | default: true 28 | manifest: 29 | description: Use a custom path for your convox.yml 30 | required: false 31 | buildargs: 32 | description: Custom build arguments for the Docker build 33 | required: false 34 | runs: 35 | using: docker 36 | image: Dockerfile 37 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Deploying" 3 | if [ -n "$INPUT_PASSWORD" ] 4 | then 5 | export CONVOX_PASSWORD=$INPUT_PASSWORD 6 | fi 7 | if [ -n "$INPUT_HOST" ] 8 | then 9 | export CONVOX_HOST=$INPUT_HOST 10 | fi 11 | export CONVOX_RACK=$INPUT_RACK 12 | 13 | # Initialize variables for the command options 14 | CACHED_COMMAND="" 15 | MANIFEST_COMMAND="" 16 | 17 | if [ "$INPUT_CACHED" = "false" ]; then 18 | CACHED_COMMAND="--no-cache" 19 | fi 20 | 21 | if [ "$INPUT_MANIFEST" != "" ]; then 22 | MANIFEST_COMMAND="-m $INPUT_MANIFEST" 23 | fi 24 | 25 | # Split the INPUT_BUILDARGS by newline into an array 26 | if [ "$INPUT_BUILDARGS" != "" ]; then 27 | IFS=$'\n' read -d '' -r -a ADDR <<< "$INPUT_BUILDARGS" # Split build arguments by newline 28 | 29 | for ARG in "${ADDR[@]}"; do 30 | # Extract key and value (handle empty lines or invalid format) 31 | KEY=${ARG%%=*} 32 | VALUE=${ARG#*=} 33 | if [[ -n "$KEY" && -n "$VALUE" ]]; then 34 | BUILDARGS_COMMAND="$BUILDARGS_COMMAND --build-args $KEY=$VALUE" 35 | fi 36 | done 37 | fi 38 | 39 | convox deploy --app $INPUT_APP --description "$INPUT_DESCRIPTION" $BUILDARGS_COMMAND $CACHED_COMMAND $MANIFEST_COMMAND 40 | --------------------------------------------------------------------------------