This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Full Workflow with Manual Approval for Deploy | |
on: | |
push: | |
branches: | |
- main # Trigger this on push to the main branch | |
jobs: | |
build: | |
name: Build Stage | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# - name: Set up Node.js | |
# uses: actions/setup-node@v2 | |
# with: | |
# node-version: '16' | |
# - name: Install dependencies | |
# run: npm install | |
- name: Build project | |
run: echo "npm run build" | |
test: | |
name: Test Stage | |
runs-on: ubuntu-latest | |
needs: build # Ensure test runs after build completes | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Run tests | |
run: echo "npm test" | |
plan: | |
name: Plan Stage | |
runs-on: ubuntu-latest | |
needs: test # Ensure plan runs after test completes | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# - name: Set up Terraform | |
# uses: hashicorp/setup-terraform@v2 | |
# with: | |
# terraform_version: "1.5.0" | |
# - name: Terraform Init | |
# working-directory: ./terraform | |
# run: terraform init -input=false | |
- name: Terraform Plan | |
# working-directory: ./terraform | |
run: echo "terraform plan -out=tfplan.binary" | |
# - name: Show Plan | |
# working-directory: ./terraform | |
# run: terraform show -no-color tfplan.binary | |
# - name: Upload Plan Artifact | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: tfplan.binary | |
# path: ./terraform/tfplan.binary | |
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 | |
# - name: Download Plan Artifact | |
# uses: actions/download-artifact@v2 | |
# with: | |
# name: tfplan.binary | |
# path: ./terraform | |
# - name: Set up Terraform | |
# uses: hashicorp/setup-terraform@v2 | |
# with: | |
# terraform_version: "1.5.0" | |
- name: Terraform Apply | |
working-directory: ./terraform | |
run: echo "end" |