Hello Node App to AWS EKS #1
This file contains hidden or 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: Hello Node App to AWS EKS | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "docker/app1-hello/node" | |
| workflow_dispatch: | |
| jobs: | |
| build-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '25' | |
| - name: Install Dependencies | |
| working-directory: docker/app1-hello/node | |
| run: npm ci | |
| - name: Run Tests (If any) | |
| working-directory: docker/app1-hello/node | |
| run: npm test --if-present | |
| docker-build-push: | |
| runs-on: ubuntu-latest | |
| needs: build-test | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v6 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and Push Docker Image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: docker/app1-hello/node | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKER_USERNAME }}/hello-node:latest | |
| deploy-aws-eks: | |
| runs-on: ubuntu-latest | |
| needs: docker-build-push | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v5.1.1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ap-south-1 | |
| - name: Setup kubectl | |
| uses: azure/setup-kubectl@v4 | |
| - name: Update kubeconfig for EKS | |
| run: | | |
| aws eks update-kubeconfig --name hello-cluster --region ap-south-1 | |
| - name: Verify connection | |
| run: kubectl get nodes | |
| - name: Deploy to AWS (Kubernetes) | |
| run: kubectl apply -f k8s/aws/app1-hello | |