-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (42 loc) · 2.04 KB
/
build-and-push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Build and Push to ACR
on:
push:
branches:
- main
- develop
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Log in to ACR
run: |
echo ${{ secrets.ACR_PASSWORD }} | docker login ${{ secrets.ACR_LOGIN_SERVER }} -u ${{ secrets.ACR_USERNAME }} --password-stdin
- name: Build and push Docker image for staging or production
run: |
# Create a tag that is common to both staging and production
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
IMAGE_TAG="staging-${{ github.sha }}"
else
IMAGE_TAG="prod-${{ github.sha }}"
fi
# Build and push the Docker image to ACR
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/chatbot-builder-executor:${IMAGE_TAG} .
docker push ${{ secrets.ACR_LOGIN_SERVER }}/chatbot-builder-executor:${IMAGE_TAG}
- name: Trigger staging deployment in k8s repo
if: github.ref == 'refs/heads/develop'
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "Accept: application/vnd.github.everest-preview+json" \
https://api.github.com/repos/Chatbot-Builder-Project/chatbot-builder-k8s/dispatches \
-d '{"event_type":"deploy_chatbot_staging", "client_payload": {"image_name": "chatbot-builder-executor", "image_tag": "staging-${{ github.sha }}"}}'
- name: Trigger production deployment in k8s repo
if: github.ref == 'refs/heads/main'
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "Accept: application/vnd.github.everest-preview+json" \
https://api.github.com/repos/Chatbot-Builder-Project/chatbot-builder-k8s/dispatches \
-d '{"event_type":"deploy_chatbot_production", "client_payload": {"image_name": "chatbot-builder-executor", "image_tag": "prod-${{ github.sha }}"}}'