|
| 1 | + |
| 2 | +name: Publish Chat21 Chat Ionic ECR |
| 3 | + |
| 4 | +env: |
| 5 | + REGISTRY: ${{ secrets.AWS_ECR_REGISTRY }}/chat21 |
| 6 | + IMAGE_NAME: chat21-ionic |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: [ dev ] |
| 11 | + |
| 12 | +jobs: |
| 13 | + push_to_registry: |
| 14 | + name: Push Docker image to ECR |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + version: ${{ steps.extract_version.outputs.VERSION }} |
| 18 | + commit-id: ${{ steps.get_commit_id.outputs.COMMIT_ID }} |
| 19 | + steps: |
| 20 | + - name: Check out the repo |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up QEMU |
| 24 | + uses: docker/setup-qemu-action@v3 |
| 25 | + with: |
| 26 | + platforms: linux/amd64,linux/arm64 |
| 27 | + |
| 28 | + - name: Set up Docker Buildx |
| 29 | + uses: docker/setup-buildx-action@v3 |
| 30 | + |
| 31 | + - name: Configure AWS credentials |
| 32 | + uses: aws-actions/configure-aws-credentials@v3 |
| 33 | + with: |
| 34 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 35 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 36 | + aws-region: ${{ secrets.AWS_REGION }} |
| 37 | + |
| 38 | + - name: Login to Amazon ECR |
| 39 | + id: login-ecr |
| 40 | + uses: aws-actions/amazon-ecr-login@v2 |
| 41 | + |
| 42 | + - name: Extract version from package.json |
| 43 | + id: extract_version |
| 44 | + run: | |
| 45 | + VERSION=$(jq -r '.version' package.json) |
| 46 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 47 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + - name: Get short commit ID |
| 50 | + id: get_commit_id |
| 51 | + run: | |
| 52 | + echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV |
| 53 | + echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + - name: Build and push to Amazon ECR |
| 56 | + uses: docker/build-push-action@v4 |
| 57 | + with: |
| 58 | + context: . |
| 59 | + file: ./Dockerfile |
| 60 | + push: true |
| 61 | + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.COMMIT_ID }} |
| 62 | + |
| 63 | + update_helm_chart: |
| 64 | + name: Update Helm Chart |
| 65 | + runs-on: ubuntu-latest |
| 66 | + needs: push_to_registry |
| 67 | + |
| 68 | + env: |
| 69 | + COMMIT_ID: ${{ needs.push_to_registry.outputs.commit-id }} |
| 70 | + VERSION: ${{ needs.push_to_registry.outputs.version }} |
| 71 | + |
| 72 | + steps: |
| 73 | + - name: Check out the Helm Chart repository |
| 74 | + uses: actions/checkout@v4 |
| 75 | + with: |
| 76 | + repository: ${{ secrets.GIT_ORG }}/${{ secrets.GIT_REPO }} |
| 77 | + token: ${{ secrets.GIT_ACTIONS_TOKEN }} |
| 78 | + path: ${{ secrets.GIT_REPO }} |
| 79 | + ref: dev |
| 80 | + |
| 81 | + - name: Install yq |
| 82 | + run: | |
| 83 | + sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq |
| 84 | + sudo chmod +x /usr/local/bin/yq |
| 85 | + yq --version |
| 86 | +
|
| 87 | + - name: Update values.yaml |
| 88 | + run: | |
| 89 | + cd ${{ secrets.GIT_REPO }}/helm |
| 90 | + yq -i '.ionic.image.tag = "${{ env.VERSION }}-${{ env.COMMIT_ID }}"' values.yaml |
| 91 | + yq -i '.ionic.image.repository = "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"' values.yaml |
| 92 | + |
| 93 | + - name: Commit and push changes |
| 94 | + run: | |
| 95 | + cd ${{ secrets.GIT_REPO }} |
| 96 | + git config user.name "Tiledesk Bot" |
| 97 | + git config user.email "tiledeskdeveloper@gmail.com" |
| 98 | + git commit -am "Update image chat21/chat21-ionic to ${{ env.VERSION }}-${{ env.COMMIT_ID }}" |
| 99 | + git push |
0 commit comments