|
| 1 | +name: Deploy to ECR |
| 2 | + |
| 3 | +on: |
| 4 | + |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + environment: |
| 8 | + description: 'Environment: Production' |
| 9 | + options: ['Production'] |
| 10 | + required: true |
| 11 | + default: 'Production' |
| 12 | +jobs: |
| 13 | + |
| 14 | + deploy: |
| 15 | + |
| 16 | + name: Deploy image to ECS |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Check out code |
| 21 | + uses: actions/checkout@v2 |
| 22 | + |
| 23 | + - uses: kamiazya/setup-graphviz@v1 |
| 24 | + |
| 25 | + |
| 26 | + - name: Configure AWS credentials |
| 27 | + uses: aws-actions/configure-aws-credentials@v1 |
| 28 | + with: |
| 29 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_moni_africa }} |
| 30 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_moni_africa }} |
| 31 | + aws-region: us-east-1 |
| 32 | + |
| 33 | + - id: commit |
| 34 | + uses: pr-mpt/actions-commit-hash@v1 |
| 35 | + |
| 36 | + - name: Login to Amazon ECR |
| 37 | + id: login-ecr |
| 38 | + uses: aws-actions/amazon-ecr-login@v1 |
| 39 | + |
| 40 | + - name: Build, tag, and push image to Amazon ECR |
| 41 | + env: |
| 42 | + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} |
| 43 | + ECR_REPOSITORY: fiter-frontend-app |
| 44 | + IMAGE_TAG: ${{ steps.commit.outputs.short }} |
| 45 | + run: | |
| 46 | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . |
| 47 | + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |
| 48 | + |
| 49 | + |
| 50 | + - name: Configure AWS credentials |
| 51 | + uses: aws-actions/configure-aws-credentials@v1 |
| 52 | + with: |
| 53 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_moni_africa }} |
| 54 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_moni_africa }} |
| 55 | + aws-region: us-east-1 |
| 56 | + |
| 57 | + - name: installing dependcies |
| 58 | + run: | |
| 59 | + curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null |
| 60 | + sudo apt-get install apt-transport-https ca-certificates curl --yes |
| 61 | + sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg |
| 62 | + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list |
| 63 | + echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list |
| 64 | + sudo apt-get update -y |
| 65 | + sudo apt-get install helm kubectl -y |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + - name: updating kubeconfig and helm repo |
| 70 | + run: | |
| 71 | + aws eks --region us-east-1 update-kubeconfig --name moni-africa-prod |
| 72 | + helm repo add fiter-apps https://chartmuseum.fiter.io/ --username ${{ secrets.CHARTMUSEUM_USERNAME }} --password ${{ secrets.CHARTMUSEUM_PASSWORD }} |
| 73 | + |
| 74 | + - name: deploy backend |
| 75 | + env: |
| 76 | + IMAGE_TAG: ${{ steps.commit.outputs.short }} |
| 77 | + run: | |
| 78 | + cd helm |
| 79 | + kubectl config set-context --current --namespace=application |
| 80 | + helm dependency update |
| 81 | + helm upgrade -i frontend --set fineract-ui.tag=$IMAGE_TAG . |
0 commit comments