NASA-PDS / devops

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

Develop Staging GitHub Action CD to deploy to Test venue #72

Open jordanpadams opened 7 months ago

jordanpadams commented 7 months ago

💡 Description

Merge to staging -> Deploy to Test venue

⚔️ Parent Epic / Related Tickets

No response

nutjob4life commented 5 months ago

Here is the prototypical staging.yaml file that would achieve this:

---
name: 🎭 Staging 
on:
    push:
        branches:
             - staging
        paths-ignore:
            - 'CHANGELOG.md'
            - 'docs/requirements/**'
    workflow_dispatch:
jobs:
    staging-delivery:
        name: 📪 Staging 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: "TERRAFORM_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:
                    ANY_SECRET: ${{secrets.ANY_SECRET}}
                    etc: ${{secrets.etc}}
            -
                name: 🛫 Terraform application of new delivery
                run: terraform apply -no-color -auto-approve
                env:
                    ANY_SECRET: ${{secrets.ANY_SECRET}}
                    etc: ${{secrets.etc}}
...

This can be adapted for various repositories depending on their shapes and needs, of course, such as adding -var-file=FILE, altering the secrets, and so on.