Skip to content

Commit

Permalink
Expand actions to support Build, Deploy, Run, and Promote (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
camerondgray authored Nov 12, 2019
1 parent 7ebe816 commit 9f3bc57
Show file tree
Hide file tree
Showing 21 changed files with 356 additions and 20 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#Github deployer for Convox

This action allows you to build and deploy apps on Convox

## Usage

### Secrets

### Environment Variables
# 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
20 changes: 20 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"

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"]
18 changes: 18 additions & 0 deletions build/README.md
Original file line number Diff line number Diff line change
@@ -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
```
16 changes: 16 additions & 0 deletions build/action.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions build/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"

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"

Expand Down
16 changes: 16 additions & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
@@ -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
```
20 changes: 20 additions & 0 deletions deploy/action.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 10 additions & 8 deletions deploy/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
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
20 changes: 20 additions & 0 deletions login/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"

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"]
15 changes: 15 additions & 0 deletions login/README.md
Original file line number Diff line number Diff line change
@@ -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 }}
```
14 changes: 14 additions & 0 deletions login/action.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions login/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions promote/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"

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"]
30 changes: 30 additions & 0 deletions promote/README.md
Original file line number Diff line number Diff line change
@@ -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
```
16 changes: 16 additions & 0 deletions promote/action.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions promote/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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

20 changes: 20 additions & 0 deletions run/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"

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"]
40 changes: 40 additions & 0 deletions run/README.md
Original file line number Diff line number Diff line change
@@ -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
```
Loading

0 comments on commit 9f3bc57

Please sign in to comment.