|
| 1 | +name: CI/CD Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v2 |
| 15 | + |
| 16 | + - name: Login to Docker Hub |
| 17 | + uses: docker/login-action@v1 |
| 18 | + with: |
| 19 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 20 | + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
| 21 | + |
| 22 | + - name: Build and push Docker image |
| 23 | + uses: docker/build-push-action@v2 |
| 24 | + with: |
| 25 | + context: . |
| 26 | + push: true |
| 27 | + tags: your-docker-username/quantum-genetic-algorithm:latest |
| 28 | + |
| 29 | + - name: Set up Kubectl |
| 30 | + uses: azure/setup-kubectl@v1 |
| 31 | + |
| 32 | + - name: Configure AWS credentials |
| 33 | + uses: aws-actions/configure-aws-credentials@v1 |
| 34 | + with: |
| 35 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 36 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 37 | + aws-region: us-west-2 |
| 38 | + |
| 39 | + - name: Install AWS IAM Authenticator |
| 40 | + run: | |
| 41 | + curl -o aws-iam-authenticator https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.9/2020-09-18/bin/linux/amd64/aws-iam-authenticator |
| 42 | + chmod +x ./aws-iam-authenticator |
| 43 | + sudo mv aws-iam-authenticator /usr/local/bin |
| 44 | +
|
| 45 | + - name: Connect to EKS cluster |
| 46 | + run: | |
| 47 | + aws eks --region us-west-2 update-kubeconfig --name your-eks-cluster-name |
| 48 | +
|
| 49 | + - name: Deploy to EKS |
| 50 | + run: | |
| 51 | + kubectl apply -f - <<EOF |
| 52 | + apiVersion: apps/v1 |
| 53 | + kind: Deployment |
| 54 | + metadata: |
| 55 | + name: quantum-genetic-algorithm |
| 56 | + spec: |
| 57 | + replicas: 1 |
| 58 | + selector: |
| 59 | + matchLabels: |
| 60 | + app: quantum-genetic-algorithm |
| 61 | + template: |
| 62 | + metadata: |
| 63 | + labels: |
| 64 | + app: quantum-genetic-algorithm |
| 65 | + spec: |
| 66 | + containers: |
| 67 | + - name: quantum-genetic-algorithm |
| 68 | + image: your-docker-username/quantum-genetic-algorithm:latest |
| 69 | + ports: |
| 70 | + - containerPort: 80 |
| 71 | + EOF |
| 72 | + |
| 73 | + kubectl apply -f - <<EOF |
| 74 | + apiVersion: v1 |
| 75 | +kind: Service |
| 76 | +metadata: |
| 77 | + name: quantum-genetic-algorithm |
| 78 | +spec: |
| 79 | + selector: |
| 80 | + app: quantum-genetic-algorithm |
| 81 | + ports: |
| 82 | + - protocol: TCP |
| 83 | + port: 80 |
| 84 | + targetPort: 80 |
| 85 | + type: LoadBalancer |
| 86 | + EOF |
0 commit comments