diff --git a/README.md b/README.md index 5ce7ad2..63e3e2f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ -#Github deployer for Convox - -This action allows you to build and deploy apps on Convox - -## Usage - -### Secrets - -### Environment Variables \ No newline at end of file +# Github Actions for Convox + +This repository contains a set of Github Actions to be used with the [Convox](https://convox.com) Platform. 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 these actions to create a complete CI/CD pipeline + +## Actions +### [convox/actions/login](./login) +Authenticates your Convox account You should run this action as the first step in your workflow +### [convox/actions/deploy](./deploy) +Builds and Promotes and App in one step +### [convox/actions/build](./build) +Builds an App and creates a release which can be promoted later +### [convox/actions/run](./run) +Runs a command (such as a migration) using a previously built release before or after it is promoted +### [convox/actions/promote](./promote) +Promotes a release \ No newline at end of file diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..2517d79 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:18.04 + +LABEL version="1.0.0" +LABEL repository="https://github.com/convox/actions/build" +LABEL homepage="https://convox.com/convox" +LABEL maintainer="Convox " + +LABEL "com.github.actions.name"="Convox Build" +LABEL "com.github.actions.description"="Build an app to deploy on Convox" +LABEL "com.github.actions.icon"="cloud" +LABEL "com.github.actions.color"="blue" + +RUN apt-get -qq update && apt-get -qq -y install curl + +RUN curl -L https://convox.com/cli/linux/convox -o /tmp/convox \ + && mv /tmp/convox /usr/local/bin/convox \ + && chmod 755 /usr/local/bin/convox + +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/build/README.md b/build/README.md new file mode 100644 index 0000000..9ed22d0 --- /dev/null +++ b/build/README.md @@ -0,0 +1,18 @@ +# Convox Build Action +This Action [builds](https://docs.convox.com/deployment/builds) an app based on a [convox.yml](https://docs.convox.com/application/convox-yml) so that app can be deployed on Convox + +## Inputs +### `rack` +**Required** The name of the [Convox Rack](https://docs.convox.com/introduction/rack) you wish to build against. +### `app` +**Required** The name of the [app](https://docs.convox.com/deployment/creating-an-application) you wish to build. +## Outputs +### `release` +The ID of the release that is created when the build completes. +## Example usage +``` +uses: convox/actions/build@v1 +with: + rack: staging + app: myapp +``` \ No newline at end of file diff --git a/build/action.yml b/build/action.yml new file mode 100644 index 0000000..f37eb1d --- /dev/null +++ b/build/action.yml @@ -0,0 +1,16 @@ +name: Convox Build +description: Build a Convox app +author: Convox +inputs: + rack: + description: Convox Rack name + required: true + app: + description: Convox app name + required: true +outputs: + release: + description: Release ID of the created build +runs: + using: docker + image: Dockerfile \ No newline at end of file diff --git a/build/entrypoint.sh b/build/entrypoint.sh new file mode 100755 index 0000000..2502381 --- /dev/null +++ b/build/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh +echo "Building" +export CONVOX_RACK=$INPUT_RACK +release=$(convox build --app $INPUT_APP --id) +echo ::set-output name=release::$release +echo ::set-env name=RELEASE::$release diff --git a/deploy/Dockerfile b/deploy/Dockerfile index b96e462..e2849bb 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -1,12 +1,12 @@ FROM ubuntu:18.04 -LABEL version="0.1.0" -LABEL repository="http://github.com/convox.actions" +LABEL version="1.0.0" +LABEL repository="https://github.com/convox/actions/deploy" LABEL homepage="https://convox.com/convox" LABEL maintainer="Convox " LABEL "com.github.actions.name"="Convox Deploy" -LABEL "com.github.actions.description"="Deploy an app to Convox" +LABEL "com.github.actions.description"="Build and Deploy an app to Convox in one step" LABEL "com.github.actions.icon"="cloud" LABEL "com.github.actions.color"="blue" diff --git a/deploy/README.md b/deploy/README.md index e69de29..f1a7c6d 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -0,0 +1,16 @@ +# Convox Deploy Action +This Action [Deploys](https://docs.convox.com/introduction/getting-started#deploy-your-application) an app based on a [convox.yml](https://docs.convox.com/application/convox-yml) to Convox. The Deploy action performs the functions of combining the [Build](../build) and [Promote](../promote) actions but in a single step. + +## Inputs +### `rack` +**Required** The name of the [Convox Rack](https://docs.convox.com/introduction/rack) you wish to deploy to. +### `app` +**Required** The name of the [app](https://docs.convox.com/deployment/creating-an-application) you wish to deploy to. + +## Example usage +``` +uses: convox/actions/deploy@v1 +with: + rack: staging + app: myapp +``` \ No newline at end of file diff --git a/deploy/action.yml b/deploy/action.yml new file mode 100644 index 0000000..cca3130 --- /dev/null +++ b/deploy/action.yml @@ -0,0 +1,20 @@ +name: Convox Deploy +description: Build and Deploy a Convox app in a single step +author: Convox +inputs: + rack: + description: Convox Rack name + required: true + app: + description: Convox app name + required: true + password: + description: Convox deploy key value + required: false + host: + description: Convox Console host address + required: false + default: console.convox.com +runs: + using: docker + image: Dockerfile \ No newline at end of file diff --git a/deploy/entrypoint.sh b/deploy/entrypoint.sh index 3285cf1..ffbf6e7 100755 --- a/deploy/entrypoint.sh +++ b/deploy/entrypoint.sh @@ -1,10 +1,12 @@ #!/bin/sh -if [ -z "$CONVOX_PASSWORD"] +echo "Deploying" +if [ -n "$INPUT_PASSWORD" ] then - echo "Convox password must be set" -else - echo "Deploying" - export CONVOX_HOST=$INPUT_CONVOX_HOST - export CONVOX_RACK=$INPUT_CONVOX_RACK - convox deploy --app $INPUT_CONVOX_APP -fi \ No newline at end of file + export CONVOX_PASSWORD=$INPUT_PASSWORD +fi +if [ -n "$INPUT_HOST" ] +then + export CONVOX_HOST=$INPUT_HOST +fi +export CONVOX_RACK=$INPUT_RACK +convox deploy --app $INPUT_APP diff --git a/login/Dockerfile b/login/Dockerfile new file mode 100644 index 0000000..bd4449b --- /dev/null +++ b/login/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:18.04 + +LABEL version="1.0.0" +LABEL repository="https://github.com/convox/actions/login" +LABEL homepage="https://convox.com/convox" +LABEL maintainer="Convox " + +LABEL "com.github.actions.name"="Convox Login" +LABEL "com.github.actions.description"="Authenticates with your Convox account" +LABEL "com.github.actions.icon"="cloud" +LABEL "com.github.actions.color"="blue" + +RUN apt-get -qq update && apt-get -qq -y install curl + +RUN curl -L https://convox.com/cli/linux/convox -o /tmp/convox \ + && mv /tmp/convox /usr/local/bin/convox \ + && chmod 755 /usr/local/bin/convox + +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/login/README.md b/login/README.md new file mode 100644 index 0000000..a93086b --- /dev/null +++ b/login/README.md @@ -0,0 +1,15 @@ +# Convox Login Action +This Action authenticates your Convox [Deploy Key](https://docs.convox.com/console/deploy-keys). You should perform this action as the first step before any other Convox actions. + +## Inputs +### `password` +**Required** The value of your [Convox Deploy Key](https://docs.convox.com/console/deploy-keys) +### `host` +**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) + +## Example usage +``` +uses: convox/actions/login@v1 +with: + password: ${{ secrets.CONVOX_DEPLOY_KEY }} +``` \ No newline at end of file diff --git a/login/action.yml b/login/action.yml new file mode 100644 index 0000000..a565f32 --- /dev/null +++ b/login/action.yml @@ -0,0 +1,14 @@ +name: Convox Login +description: Login to Convox +author: Convox +inputs: + password: + description: Convox deploy key value + required: true + host: + description: Convox Console host address + required: false + default: console.convox.com +runs: + using: docker + image: Dockerfile \ No newline at end of file diff --git a/login/entrypoint.sh b/login/entrypoint.sh new file mode 100755 index 0000000..680eb3a --- /dev/null +++ b/login/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh +echo "Setting login credentials" +echo ::set-env name=CONVOX_PASSWORD::$INPUT_PASSWORD +echo ::set-env name=CONVOX_HOST::$INPUT_HOST \ No newline at end of file diff --git a/promote/Dockerfile b/promote/Dockerfile new file mode 100644 index 0000000..54332a1 --- /dev/null +++ b/promote/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:18.04 + +LABEL version="1.0.0" +LABEL repository="https://github.com/convox/actions/promote" +LABEL homepage="https://convox.com/convox" +LABEL maintainer="Convox " + +LABEL "com.github.actions.name"="Convox Promote" +LABEL "com.github.actions.description"="Promote a release" +LABEL "com.github.actions.icon"="cloud" +LABEL "com.github.actions.color"="blue" + +RUN apt-get -qq update && apt-get -qq -y install curl + +RUN curl -L https://convox.com/cli/linux/convox -o /tmp/convox \ + && mv /tmp/convox /usr/local/bin/convox \ + && chmod 755 /usr/local/bin/convox + +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/promote/README.md b/promote/README.md new file mode 100644 index 0000000..2f57d8c --- /dev/null +++ b/promote/README.md @@ -0,0 +1,30 @@ +# Convox Promote Action +This Action [Promotes](https://docs.convox.com/deployment/releases#promoting-a-release) a previously built app to Convox. You will typically need to perform the [Build](../build) action prior to running this action. + +## Inputs +### `rack` +**Required** The name of the [Convox Rack](https://docs.convox.com/introduction/rack) you wish to deploy to. +### `app` +**Required** The name of the [app](https://docs.convox.com/deployment/creating-an-application) you wish to deploy. +### `release` +**Optional** The ID of the [release](https://docs.convox.com/deployment/releases) you wish to promote. If you have run a [Build](../build) action as a previous step this step will promote the release created by that build step by default. You only need to set the release if you have not run a build step first or you wish to override the release id from the build step + +## Example usage +``` +steps: +- name: login + uses: convox/actions/login@v1 + with: + password: ${{ secrets.CONVOX_DEPLOY_KEY }} +- name: build + id: build + uses: convox/actions/build@v1 + with: + rack: staging + app: myapp +- name: promote + uses: convox/actions/promote@v1 + with: + rack: staging + app: myapp +``` \ No newline at end of file diff --git a/promote/action.yml b/promote/action.yml new file mode 100644 index 0000000..1f9d861 --- /dev/null +++ b/promote/action.yml @@ -0,0 +1,16 @@ +name: Convox Promote +description: Promote a release +author: Convox +inputs: + rack: + description: Convox Rack name + required: true + app: + description: Convox app name + required: true + release: + description: ID of the release to promote. Only needed if you have not run a build step first or you wish to override the release id from the build + required: false +runs: + using: docker + image: Dockerfile \ No newline at end of file diff --git a/promote/entrypoint.sh b/promote/entrypoint.sh new file mode 100755 index 0000000..091f112 --- /dev/null +++ b/promote/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh +#!/bin/sh +if [ -n "$INPUT_RELEASE" ] +then + export RELEASE=$INPUT_RELEASE +fi +if [ -z "$RELEASE" ] +then + echo "Release must either be passed as input or set by running a build step" + exit 1 +else + echo "Promoting Release $RELEASE" + export CONVOX_RACK=$INPUT_RACK + convox releases promote $RELEASE --app $INPUT_APP +fi + diff --git a/run/Dockerfile b/run/Dockerfile new file mode 100644 index 0000000..5af517c --- /dev/null +++ b/run/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:18.04 + +LABEL version="1.0.0" +LABEL repository="https://github.com/convox/actions/run" +LABEL homepage="https://convox.com/convox" +LABEL maintainer="Convox " + +LABEL "com.github.actions.name"="Convox Run" +LABEL "com.github.actions.description"="Run a command" +LABEL "com.github.actions.icon"="cloud" +LABEL "com.github.actions.color"="blue" + +RUN apt-get -qq update && apt-get -qq -y install curl + +RUN curl -L https://convox.com/cli/linux/convox -o /tmp/convox \ + && mv /tmp/convox /usr/local/bin/convox \ + && chmod 755 /usr/local/bin/convox + +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/run/README.md b/run/README.md new file mode 100644 index 0000000..9b8a022 --- /dev/null +++ b/run/README.md @@ -0,0 +1,40 @@ +# Convox Run Action +This Action runs a [One-off Command](https://docs.convox.com/management/one-off-commands) using a specific release of an app on Convox. A typical use case of this action would be to run migrations or a similar pre-deploy or post-deploy command. + +## Inputs +### `rack` +**Required** The name of the [Convox Rack](https://docs.convox.com/introduction/rack) containing the app you wish to run the command against +### `app` +**Required** The name of the [app](https://docs.convox.com/deployment/creating-an-application) you wish to run the command against +### `service` +**Required** The name of the [service](https://docs.convox.com/application/services) to run the command against +### `command` +**Required** The command you wish to run +### `release` +**Optional** The ID of the [release](https://docs.convox.com/deployment/releases) you wish to run the command against. This ID is output as `release` by the [Build](../build) action. Only needed if you have not run a build step first or you wish to override the release id from the build step +## Example usage +``` +steps: +- name: login + uses: convox/actions/login@v1 + with: + password: ${{ secrets.CONVOX_DEPLOY_KEY }} +- name: build + id: build + uses: convox/actions/build@v1 + with: + rack: staging + app: myapp +- name: run + uses: convox/actions/run@v1 + with: + rack: staging + app: myapp + service: web + command 'rake db:migrate' +- name: promote + uses: convox/actions/promote@v1 + with: + rack: staging + app: myapp +``` \ No newline at end of file diff --git a/run/action.yml b/run/action.yml new file mode 100644 index 0000000..7d5c87d --- /dev/null +++ b/run/action.yml @@ -0,0 +1,22 @@ +name: Convox Run +description: Run a command +author: Convox +inputs: + rack: + description: Convox Rack name + required: true + app: + description: Convox app name + required: true + service: + description: The service to run the command against + required: true + command: + description: The command to be run + required: true + release: + description: ID of the release to run the command against. Only needed if you have not run a build step first or you wish to override the release id from the build step + required: false +runs: + using: docker + image: Dockerfile \ No newline at end of file diff --git a/run/entrypoint.sh b/run/entrypoint.sh new file mode 100755 index 0000000..334a1aa --- /dev/null +++ b/run/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/sh +if [ -n "$INPUT_RELEASE" ] +then + export RELEASE=$INPUT_RELEASE +fi +if [ -z "$RELEASE" ] +then + echo "Release must either be passed as input or set by running a build step" + exit 1 +else + echo "Running command" + export CONVOX_RACK=$INPUT_RACK + convox run $INPUT_SERVICE "$INPUT_COMMAND" --release $RELEASE --app $INPUT_APP --rack $INPUT_RACK +fi +