-
Notifications
You must be signed in to change notification settings - Fork 2
112 lines (94 loc) · 3.94 KB
/
master.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Build and deploy
on:
push:
branches: [ master ]
jobs:
cancel-previous:
name: 'Cancel Previous Runs'
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
unique_id:
runs-on: ubuntu-18.04
steps:
- name: Generate unique id
id: unique_id
run: echo "::set-output name=id::$(uuidgen)"
outputs:
unique_id: ${{ steps.unique_id.outputs.id }}
install-build-and-push:
runs-on: ubuntu-18.04
needs: [cancel-previous, unique_id]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2-beta
with:
node-version: '14'
- name: Check dependency versions
run: node common/scripts/install-run-rush.js check
- name: Install application
run: |
node common/scripts/install-run-rush.js update
- name: Build application
run: node common/scripts/install-run-rush.js rebuild --verbose
- name: Build containers
run: node common/scripts/install-run-rush.js build:container --verbose
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build & push docker images
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
BUILD_ID: ${{needs.unique_id.outputs.unique_id}}
run: |
docker tag energyweb/dsb-message-broker:canary $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:canary
docker push $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:canary
docker tag $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:canary $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:$BUILD_ID
docker push $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:$BUILD_ID
- name: Logout of Amazon ECR
if: always()
run: docker logout ${{ steps.login-ecr.outputs.registry }}
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Build and push image'
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker tag ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPOSITORY }}:${{needs.unique_id.outputs.unique_id}} ${{ secrets.REGISTRY_LOGIN_SERVER }}/dsb/messagebroker:${{needs.unique_id.outputs.unique_id}}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/dsb/messagebroker:${{needs.unique_id.outputs.unique_id}}
docker tag ${{ secrets.REGISTRY_LOGIN_SERVER }}/dsb/messagebroker:${{needs.unique_id.outputs.unique_id}} ${{ secrets.REGISTRY_LOGIN_SERVER }}/dsb/messagebroker:canary
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/dsb/messagebroker:canary
- name: ArgoCD login
uses: clowdhaus/argo-cd-action/@main
id: argocd_login
with:
command: login ${{ secrets.ARGOCD_DEV_URL }}
options: --insecure --password ${{ secrets.ARGOCD_DEV_PASS }} --username ${{ secrets.ARGOCD_DEV_USERNAME }}
- name: ArgoCD overvrite values.yaml
uses: clowdhaus/argo-cd-action/@main
id: argocd_image_tag_overwrite
with:
command: app set dsb-messagebroker
options: -p dsb-messagebroker.image.tag=${{needs.unique_id.outputs.unique_id}}
- name: ArgoCD overwrite values.yaml - dsb test
uses: clowdhaus/argo-cd-action/@main
id: argocd_image_tag_overwrite_dsb_test
with:
command: app set dsb-messagebroker-test
options: -p dsb-messagebroker.image.tag=${{needs.unique_id.outputs.unique_id}}