NASA-PDS / devops

Parent repo for PDS DevOps activities
Apache License 2.0
0 stars 0 forks source link

Develop Unstable GitHub Action CD to Dev venue #71

Open jordanpadams opened 2 months ago

jordanpadams commented 2 months ago

💡 Description

Merge to develop branch -> deploy to Dev venue in AWS

⚔️ Parent Epic / Related Tickets

No response

tloubrieu-jpl commented 2 months ago

A sandbox repository has been is being created to test the deployment.

tloubrieu-jpl commented 1 month ago

@nutjob4life was able to make a terraform script to be applied and deploy components on a DEV environment. @tloubrieu-jpl will create a meeting with @nutjob4life and @sjoshi-jpl to start to apply that on one repository, e.g. registry-api.

nutjob4life commented 2 weeks ago

Here is a basic terraform workflow for a DEV tier delivery (assuming the branch is called develop) that we can adapt:

---
name: 🔧 Development 
on:
    push:
        branches:
             - develop
        paths-ignore:
            - 'CHANGELOG.md'
            - 'docs/requirements/**'
    workflow_dispatch:
jobs:
    development-delivery:
        name: 📪 Development Delivery
        if: github.actor != 'pdsen-ci'
        runs-on: ubuntu-latest
        steps:
            -
                name: 💳 Checkout
                uses: actions/checkout@v2
                with:
                    lfs: true
                    token: ${{secrets.ADMIN_GITHUB_TOKEN}}
                    fetch-depth: 0
            -
                name: 🌍 Terraform Setup
                uses: hashicorp/setup-terraform@v3
                with:
                    terraform_version: "PUT_VERSION_HERE"
            -
                name: 🔬 Terraform initialization and validation
                run: |
                    terraform init -no-color
                    terraform validate -no-color
            -
                name: 💥 Terraform destruction of any existing delivery
                run: terraform apply -destroy -no-color -auto-approve
                continue-on-error: true
                env:
                    WHATEVER_SECRET: ${{secrets.WHATEVER}}
            -
                name: 🛫 Terraform application of new delivery
                run: terraform apply -no-color -auto-approve
                env:
                    WHATEVER_SECRET: ${{secrets.WHATEVER}}
...

For more complex projects, simply expand on this, such as cd terraform for repositories that organize all .tf files in a single place; or add -var-file to terraform apply to give different sets of variables; to providing different environment secrets, etc.