Docker Build and Kubernetes Deploy #5
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: Docker Build and Kubernetes Deploy | |
on: | |
workflow_dispatch: | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
# - name: Build and push Docker images | |
# run: | | |
# docker build -t hellopradum/backend-wanderlust backend/. | |
# docker build -t hellopradum/frontend-wanderlust frontend/. | |
# docker push hellopradum/backend-wanderlust:latest | |
# docker push hellopradum/frontend-wanderlust:latest | |
- name: Install kubectl | |
run: | | |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | |
chmod +x kubectl | |
sudo mv kubectl /usr/local/bin/ | |
- name: Configure kubectl | |
run: | | |
mkdir -p ~/.kube | |
echo "${{ secrets.KUBE_CONFIG }}" | base64 --decode > ${HOME}/.kube/config | |
cat ${HOME}/.kube/config | |
kubectl version --client | |
- name: Create and claim persistent volume | |
run: | | |
cd kubernetes | |
kubectl apply -f persistentVolume.yaml | |
kubectl apply -f persistentVolumeClaim.yaml | |
- name: Deploy MongoDB | |
run: | | |
kubectl apply -f mongodb.yaml | |
- name: Deploy Redis | |
run: | | |
kubectl apply -f redis.yaml | |
- name: Deploy Backend | |
run: | | |
kubectl apply -f backend.yaml | |
- name: Deploy Frontend | |
run: | | |
kubectl apply -f frontend.yaml |