Skip to content

Commit

Permalink
fixes and add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
boetro committed Nov 22, 2023
1 parent 43eff57 commit cac86a1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
55 changes: 53 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
# actions-promote
Reusable actions for promoting environments in LaunchFLow
# LaunchFlow actions-promote

A GitHub action for promoting deployments between [environments](https://docs.launchflow.com/launchflow-cloud/user-guides/environments) in LaunchFlow. This action can be used to promote a deployment running in one environment to another. For instance you can use this action to promote a deployment running in the `dev` environment to the `prod` environment.

## Prerequisites

- Create a [LaunchFlow project](https://docs.launchflow.com/launchflow-cloud/user-guides/projects)
- Create [two environments]((https://docs.launchflow.com/launchflow-cloud/user-guides/environments)) in your LaunchFlow project
- [Launch a deployment](](https://docs.launchflow.com/launchflow-cloud/user-guides/create-a-deployment) ) in the environment you are promoting from

## Usage

The below is an example from promoting from a `dev` environment to a `prod` environment. This will take the deployment running in the `dev` environment and launch in in the `prod` environment. You need to provide the environment names, the deployment key for the `prod` environment, and the project ID the environments live in. We recommend storing the project ID and deployment key as secrets in your repository.

```yaml
on:
workflow_dispatch:

name: Release Prod
concurrency: prod
jobs:
release-prod:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: "write"
environment: prod
steps:
- uses: "actions/checkout@v3"

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Promote to Prod
uses: launchflow/actions-promote@main
with:
project_id: ${{ secrets.LAUNCHFLOW_PROJECT_ID }}
from_environment_name: dev
to_environment_name: prod
deployment_key: ${{ secrets.LAUNCHFLOW_PROD_DEPLOYMENT_KEY }}

```

## Inputs

| Input | Description |
|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| project_id | The LaunchFlow project to deploy to. Should be of the format `project_XXXXXX` |
| from_environment_name | The environment in the project that you are promoting from (from -> to). This should match the name you provided when you created your environment (e.g. `dev`) |
| to_environment_name | The environment in the project that you are promoting to (from -> to). This should match the name you provided when you created your environment (e.g. `prod` ) |
| deployment_key | The LaunchFlow deployment key of the environment you are promoting **to** use for authentication. This key is initially generated when you create your environment. |
1 change: 0 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ runs:
INPUT_TO_ENVIRONMENT: ${{ inputs.to_environment_name }}
INPUT_PROJECT_ID: ${{ inputs.project_id }}
INPUT_DKEY: ${{ inputs.deployment_key }}
INPUT_WORKING_DIR: ${{ inputs.working_dir }}
shell: bash
5 changes: 2 additions & 3 deletions action/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
TO_ENVIRONMENT = os.environ["INPUT_TO_ENVIRONMENT"]
PROJECT = os.environ["INPUT_PROJECT_ID"]
DKEY = os.environ["INPUT_DKEY"]
WORKING_DIR = os.environ["INPUT_WORKING_DIR"]

version_specifier = ""
if VERSION != "":
Expand All @@ -25,7 +24,7 @@
cmd = "launch config set-server-address https://dev.apis.launchflow.com"
check_call(cmd, shell=True)
cmd = (
"launch deployments promte-environment "
"launch deployments promote-environment "
f"-t={TO_ENVIRONMENT} -f=INPUT_TO_ENVIRONMENT --project-id={PROJECT} --dkey={DKEY}"
)
check_call(cmd, shell=True, cwd=WORKING_DIR)
check_call(cmd, shell=True)

0 comments on commit cac86a1

Please sign in to comment.