Skip to content

Commit

Permalink
end test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hermann90 committed Nov 5, 2024
1 parent 3c1e170 commit 2a54925
Showing 1 changed file with 40 additions and 85 deletions.
125 changes: 40 additions & 85 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,122 +1,77 @@
name: Terraform CI/CD Pipeline
name: Full Workflow with Manual Approval for Deploy

on:
push:
branches:
- main
pull_request:
branches:
- main

# env:
# TF_VERSION: "1.5.0"
# TF_WORKING_DIR: "./terraform" # Adjust to your Terraform directory
- main # Trigger this on push to the main branch

jobs:
format:
name: Terraform Format
build:
name: Build Stage
runs-on: ubuntu-latest
steps:
- name: Checkout Code
- name: Checkout code
uses: actions/checkout@v2

# - name: Setup Terraform
# uses: hashicorp/setup-terraform@v2
# - name: Set up Node.js
# uses: actions/setup-node@v2
# with:
# terraform_version: ${{ env.TF_VERSION }}
# node-version: '16'

- name: Run Terraform Format
run: echo "step 1"
# - name: Install dependencies
# run: npm install

validate:
name: Terraform Validate
- name: Build project
run: echo "npm run build"

test:
name: Test Stage
runs-on: ubuntu-latest
needs: format
needs: build # Ensure test runs after build completes
steps:
- name: Checkout Code
- name: Checkout code
uses: actions/checkout@v2

# - name: Setup Terraform
# uses: hashicorp/setup-terraform@v2
# with:
# terraform_version: ${{ env.TF_VERSION }}

- name: Run Terraform Validate
working-directory: ${{ env.TF_WORKING_DIR }}
run: echo "step 2"
- name: Run tests
run: echo "npm test"

plan:
name: Terraform Plan
name: Plan Stage
runs-on: ubuntu-latest
needs: validate
needs: test # Ensure plan runs after test completes
steps:
- name: Checkout Code
- name: Checkout code
uses: actions/checkout@v2

- name: Run Terraform Validate
working-directory: ${{ env.TF_WORKING_DIR }}
run: echo "step 3"

# - name: Setup Terraform
# - name: Set up Terraform
# uses: hashicorp/setup-terraform@v2
# with:
# terraform_version: ${{ env.TF_VERSION }}
# terraform_version: "1.5.0"

# - name: Terraform Init
# working-directory: ${{ env.TF_WORKING_DIR }}
# run: terraform init -input=false
# working-directory: ./terraform
# run: terraform init -input=false

# - name: Terraform Plan
# working-directory: ${{ env.TF_WORKING_DIR }}
# run: terraform plan -out=tfplan.binary
- name: Terraform Plan
working-directory: ./terraform
run: echo "terraform plan -out=tfplan.binary"

# - name: Show Terraform Plan
# working-directory: ${{ env.TF_WORKING_DIR }}
# - name: Show Plan
# working-directory: ./terraform
# run: terraform show -no-color tfplan.binary

manual-approval:
name: Manual Approval Before Apply
runs-on: ubuntu-latest
needs: plan
if: github.event_name == 'push' # Only require approval on main branch pushes
steps:
- name: Approval Needed
run: echo "Please review and approve before deploying."

apply:
name: Terraform Apply
runs-on: ubuntu-latest
needs: manual-approval
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Terraform Init
working-directory: ${{ env.TF_WORKING_DIR }}
run: echo "SUCESSS"

# - name: Setup Terraform
# uses: hashicorp/setup-terraform@v2
# with:
# terraform_version: ${{ env.TF_VERSION }}

# - name: Terraform Init
# working-directory: ${{ env.TF_WORKING_DIR }}
# run: terraform init -input=false

# - name: Apply Terraform Plan
# working-directory: ${{ env.TF_WORKING_DIR }}
# run: terraform apply -auto-approve tfplan.binary

name: Manual Deploy Stage

on:
workflow_dispatch:
# - name: Upload Plan Artifact
# uses: actions/upload-artifact@v2
# with:
# name: tfplan.binary
# path: ./terraform/tfplan.binary

jobs:
deploy:
name: Deploy Stage
runs-on: ubuntu-latest
needs: plan # Ensure deploy runs after plan completes
environment:
name: production # This triggers environment approval
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -134,4 +89,4 @@ jobs:

- name: Terraform Apply
working-directory: ./terraform
run: echo "TEST END"
run: echo "end"

0 comments on commit 2a54925

Please sign in to comment.