Update Deployment.yml #12
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: Test and Deploy to Minikube | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
test_and_deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the code from the repository | |
- name: Check out code | |
uses: actions/checkout@v2 | |
# Step 2: Snyk Vulnerability Scan | |
- name: Snyk Code and Dependency Scan | |
uses: snyk/actions/node@master # Use the latest stable version | |
with: | |
command: test | |
args: server | |
env: | |
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
# Step 4: Install Docker | |
- name: Install Docker | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list | |
sudo apt-get update | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io | |
sudo systemctl start docker | |
sudo systemctl enable docker | |
# Step 5: Install Minikube | |
- name: Install Minikube | |
run: | | |
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 | |
sudo install minikube-linux-amd64 /usr/local/bin/minikube | |
# Clean up the downloaded file | |
rm minikube-linux-amd64 | |
# Step 6: Start Minikube | |
- name: Start Minikube | |
run: | | |
minikube start --driver=docker | |
# Step 7: Set up kubectl | |
- name: Set up kubectl | |
run: | | |
KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) && \ | |
echo "Downloading kubectl version: ${KUBECTL_VERSION}" && \ | |
curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" && \ | |
sudo install kubectl /usr/local/bin/ && \ | |
# Clean up the downloaded file | |
rm kubectl | |
# Step 8: Create namespace | |
- name: Create namespace | |
run: | | |
kubectl create namespace myapp || echo "Namespace 'myapp' already exists" | |
# Step 9: Run OWASP ZAP scan | |
- name: Run OWASP ZAP scan | |
run: | | |
docker run -t owasp/zap2docker-stable zap-baseline.py -t localhost:3000 | |