Skip to content

Commit

Permalink
(BPD-1443) Implement GitHub action workflows integrated with Pulumi (#3)
Browse files Browse the repository at this point in the history
* task: Add .secrets to .gitignore

* task: Add the two workflows and requirements file

* task: Specify develop branch for preview workflow

* task: Remove unnecessary workflow files

* task: Secrets manager retrieval for preview workflow

* task: Remove AWS CLI installation from GH Actions

* task: Remove AWS CLI installation from deploy WF
  • Loading branch information
adrianmf94 authored Jun 21, 2024
1 parent 27fdd47 commit c6aed06
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 214 deletions.
72 changes: 0 additions & 72 deletions .github/workflows/_lint.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/build_deploy_image.yml

This file was deleted.

105 changes: 0 additions & 105 deletions .github/workflows/ci.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Pulumi Deploy
on:
push:
branches:
- develop
jobs:
preview:
name: Preview
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.AWS_REGION }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

# Retrieve and set environment variables from AWS Secrets Manager
- name: Retrieve secrets from AWS Secrets Manager
run: |
aws secretsmanager get-secret-value --secret-id opengpts-env-variables --query 'SecretString' --output text | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' > .env
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}

# Create and activate the virtual environment
- name: Set up Python virtual environment
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
# Update the Pulumi stack
- uses: pulumi/actions@v5
with:
command: up
stack-name: brighthive/bb-assistants-dev
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/preview-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Pulumi Preview
on:
pull_request:
branches:
- develop

jobs:
preview:
name: Preview
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: ${{ secrets.AWS_REGION }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

# Retrieve and set environment variables from AWS Secrets Manager
- name: Retrieve secrets from AWS Secrets Manager
run: |
aws secretsmanager get-secret-value --secret-id opengpts-env-variables --query 'SecretString' --output text | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' > .env
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}

# Create and activate the virtual environment
- name: Set up Python virtual environment
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
- uses: pulumi/actions@v5
with:
command: preview
stack-name: brighthive/bb-assistants-dev
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ pnpm-debug.log*
# Temp Lambda files:
backend/lambda_*
lambda_*/

# Secrets files
.secrets
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pulumi>=3.0.0,<4.0.0
pulumi-random>=4.0.0,<5.0.0
pulumi-aws
pulumi-docker
python-dotenv

0 comments on commit c6aed06

Please sign in to comment.