Skip to content

Commit dd1f7ba

Browse files
author
Gabriele Panico
committed
added: dev gitaction
1 parent ff4695e commit dd1f7ba

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

.github/workflows/dev.yml

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

0 commit comments

Comments
 (0)