diff --git a/.github/workflows/production_deployment.yml b/.github/workflows/production_deployment.yml index b48bf1c..92fe036 100644 --- a/.github/workflows/production_deployment.yml +++ b/.github/workflows/production_deployment.yml @@ -18,20 +18,37 @@ jobs: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} IMAGE_NAME: fyle_qbd-api - - name: Deploy to Production - uses: fylein/aws-eks-deploy-action@master - env: - EKS_CLUSTER_NAME: ${{ secrets.EKS_CLUSTER_NAME }} - AWS_REGION: ${{ secrets.AWS_REGION }} - LOCAL_HOST: ${{ secrets.LOCAL_HOST }} - LOCAL_PORT: ${{ secrets.LOCAL_PORT }} - REMOTE_PORT: ${{ secrets.REMOTE_PORT }} - EKS_KUBECTL_ROLE: ${{ secrets.EKS_KUBECTL_ROLE }} - ROLE_SESSION_NAME: ${{ secrets.ROLE_SESSION_NAME }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - KUBERNETES_MANIFEST_FILE_PATH: deployment/production/controller.yml + + - name: Install kustomize + run: | + curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash + sudo mv kustomize /usr/local/bin/ + + - name: Clone another repository + uses: actions/checkout@v2 + with: + repository: ${{ secrets.PROD_DEPLOY_REPO }} + ref: master + path: ${{ secrets.PROD_DEPLOY_REPO }} + persist-credentials: false + token: ${{ secrets.DEPLOY_GIT_ACCESS_TOKEN }} + + - name: Update Image Tag + run: | + NEW_TAG="v$(git rev-parse --short HEAD)" + cd ${{ secrets.PROD_DEPLOY_REPO }}/${{ secrets.EKS_CLUSTER_NAME }}/integrations + kustomize edit set image docker.io/${{ secrets.DOCKERHUB_USERNAME }}/fyle_qbd-api=docker.io/${{ secrets.DOCKERHUB_USERNAME }}/fyle_qbd-api:$NEW_TAG + + - name: Commit and push changes + run: | + cd ${{ secrets.PROD_DEPLOY_REPO }}/ + git config --global user.email "integrations@fylehq.com" + git config --global user.name "GitHub Actions" + git add . + git commit -m "Update image tag" + git remote set-url origin https://x-access-token:${{ secrets.DEPLOY_GIT_ACCESS_TOKEN }}@github.com/${{ secrets.PROD_DEPLOY_REPO }} + git push origin master + - name: Create new Sentry release env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} @@ -50,13 +67,3 @@ jobs: # Create new deploy for this Sentry release sentry-cli releases deploys $SENTRY_RELEASE new -e $SENTRY_DEPLOY_ENVIRONMENT - - name: Slack Notification - uses: rtCamp/action-slack-notify@v2 - env: - SLACK_COLOR: ${{ job.status }} - SLACK_MESSAGE: Production Deploy Status - ${{ job.status }} - SLACK_TITLE: Deploy QuickBooks Desktop API to Production - SLACK_ICON_EMOJI: ":pepeok:" - SLACK_USERNAME: qbd-api_API - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_FOOTER: '' \ No newline at end of file diff --git a/deployment/production/controller.yml b/deployment/production/controller.yml deleted file mode 100644 index 8ed84cc..0000000 --- a/deployment/production/controller.yml +++ /dev/null @@ -1,94 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: qbd-api - namespace: integrations - labels: - app: qbd-api -spec: - ports: - - port: 8000 - selector: - app: qbd-api - type: ClusterIP ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: qbd-api - namespace: integrations - labels: - app: qbd-api -spec: - replicas: 1 - selector: - matchLabels: - app: qbd-api - strategy: - type: RollingUpdate - template: - metadata: - labels: - app: qbd-api - spec: - containers: - - name: qbd-api - image: docker.io/{{DOCKERHUB_USERNAME}}/fyle_qbd-api:{{RELEASE_VERSION}} - resources: - limits: - memory: 200Mi - requests: - memory: 150Mi - env: - - name: GET_HOSTS_FROM - value: dns - ports: - - containerPort: 8000 - readinessProbe: - httpGet: - path: /api/workspaces/ready/ - port: 8000 - initialDelaySeconds: 10 - timeoutSeconds: 1 - envFrom: - - secretRef: - name: qbd-api-secrets - imagePullSecrets: - - name: myregistrykey2 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: qbd-api-qcluster - namespace: integrations - labels: - app: qbd-api-qcluster -spec: - replicas: 1 - selector: - matchLabels: - app: qbd-api-qcluster - strategy: - type: RollingUpdate - template: - metadata: - labels: - app: qbd-api-qcluster - spec: - containers: - - name: qbd-api - image: docker.io/{{DOCKERHUB_USERNAME}}/fyle_qbd-api:{{RELEASE_VERSION}} - command: ['/bin/bash', 'start_qcluster.sh'] - resources: - limits: - memory: 450Mi - requests: - memory: 350Mi - env: - - name: GET_HOSTS_FROM - value: dns - envFrom: - - secretRef: - name: qbd-api-secrets - imagePullSecrets: - - name: myregistrykey2 \ No newline at end of file