@@ -12,11 +12,22 @@ jobs:
12
12
runs-on : ubuntu-latest
13
13
steps :
14
14
- name : Check out the repo
15
- uses : actions/checkout@v3
15
+ uses : actions/checkout@v4
16
+ if : github.event_name != 'pull_request'
16
17
with :
17
18
ref : " ${{env.GITHUB_SHA}}"
18
19
token : ${{ secrets.DEVOPS_GITHUB_PERMANENT_TOKEN }}
19
20
21
+ # - name: Docker meta
22
+ # id: meta
23
+ # uses: docker/metadata-action@v5
24
+ # with:
25
+ # images: push-backend
26
+ # tags: |
27
+ # type=semver,pattern={{version}}-develop
28
+ # type=semver,pattern={{version}}-staging
29
+ # type=semver,pattern={{version}}
30
+
20
31
- name : Set variables
21
32
run : |
22
33
TAG="$( echo "${GITHUB_REF}" | cut -d'/' -f3 )"
41
52
echo "IMAGE_SOURCE_URL=https://github.com/weni-ai/flows" | tee -a "${GITHUB_ENV}"
42
53
echo "MANIFESTS_REPOSITORY=weni-ai/kubernetes-manifests-platform" | tee -a "${GITHUB_ENV}"
43
54
echo "MANIFESTS_APPLICATION=weni-flows/flows" | tee -a "${GITHUB_ENV}"
44
- echo "MANIFESTS_PATCH_TARGET=deployment-flows.json" | tee -a "${GITHUB_ENV}"
45
- echo "MANIFESTS_PATCH_TARGET1=deployment-flows-image.json" | tee -a "${GITHUB_ENV}"
55
+ echo "MANIFESTS_PATCH_TARGET=deployment-flows-image.json" | tee -a "${GITHUB_ENV}"
46
56
47
57
FLOWEDITOR_VERSION=$(jq -r '.dependencies["@nyaruka/flow-editor"]' < package.json)
48
58
echo "FLOWEDITOR_VERSION=${FLOWEDITOR_VERSION}" | tee -a "${GITHUB_ENV}"
@@ -53,56 +63,90 @@ jobs:
53
63
fi
54
64
echo "FLOWEDITOR_BRANCH=$FLOWEDITOR_BRANCH" | tee -a "${GITHUB_ENV}"
55
65
56
-
57
66
- name : Set up QEMU
58
- uses : docker/setup-qemu-action@v2
67
+ uses : docker/setup-qemu-action@v3
59
68
60
69
- name : Set up Docker Buildx
61
- uses : docker/setup-buildx-action@v2
70
+ uses : docker/setup-buildx-action@v3
62
71
63
72
- name : Login to ECR
64
- uses : docker/login-action@v2
73
+ uses : docker/login-action@v3
74
+ if : github.event_name != 'pull_request'
65
75
with :
66
76
registry : ${{ secrets.ECR }}
67
- username : ${{ secrets.AWS_ACCESS_KEY_ID_SHARED }}
77
+ username : ${{ secrets.AWS_ACCESS_KEY_ID_SHARED }}
68
78
password : ${{ secrets.AWS_SECRET_ACCESS_KEY_SHARED }}
69
79
80
+ # Cache
81
+ - name : Cache var-cache-apt
82
+ uses : actions/cache@v3
83
+ with :
84
+ path : var-cache-apt
85
+ key : var-cache-apt-${{ hashFiles('docker/Dockerfile') }}
86
+ - name : Cache var-lib-apt
87
+ uses : actions/cache@v3
88
+ with :
89
+ path : var-lib-apt
90
+ key : var-lib-apt-${{ hashFiles('docker/Dockerfile') }}
91
+ - name : Cache pip
92
+ uses : actions/cache@v3
93
+ with :
94
+ path : cache-pip
95
+ key : cache-pip-${{ hashFiles('docker/Dockerfile') }}
96
+ - name : Cache npm
97
+ uses : actions/cache@v3
98
+ with :
99
+ path : cache-npm
100
+ key : cache-npm-${{ hashFiles('docker/Dockerfile') }}
101
+
102
+ # Inject cache
103
+ - name : inject var-cache-apt into docker
104
+ uses :
reproducible-containers/[email protected]
105
+ with :
106
+ cache-source : var-cache-apt
107
+ cache-target : /var/cache/apt
108
+ - name : inject var-lib-apt into docker
109
+ uses :
reproducible-containers/[email protected]
110
+ with :
111
+ cache-source : var-lib-apt
112
+ cache-target : /var/lib/apt
113
+ - name : inject pip cache into docker
114
+ uses :
reproducible-containers/[email protected]
115
+ with :
116
+ cache-source : cache-pip
117
+ cache-target : /pip_cache
118
+ - name : inject npm cache into docker
119
+ uses :
reproducible-containers/[email protected]
120
+ with :
121
+ cache-source : cache-npm
122
+ cache-target : /npm_cache
123
+
70
124
- name : Build and push - Flows Image
71
- uses : docker/build-push-action@v3
125
+ uses : docker/build-push-action@v5
72
126
with :
127
+ cache-from : type=gha
128
+ cache-to : type=gha,mode=max
73
129
context : .
74
130
labels : |
75
131
tag=${{env.TAG}}
76
132
commit=${{env.COMMIT_SHA}}
77
133
repository=${{env.IMAGE_SOURCE_URL}}
78
134
file : docker/Dockerfile
79
- push : true
135
+ push : ${{ github.event_name != 'pull_request' }}
80
136
tags : " ${{env.IMAGE_TAG}}"
81
- no-cache : true
137
+ # tags: ${{ steps.meta.outputs.tags }}
138
+ # platforms: linux/amd64,linux/arm64,linux/arm/v7,darwin/amd64,linux/arm/v8
139
+ # no-cache: true
82
140
build-args : |
83
141
FLOWEDITOR_VERSION=${{ env.FLOWEDITOR_VERSION }}
84
142
FLOWEDITOR_REPO=${{ env.FLOWEDITOR_REPO }}
85
143
FLOWEDITOR_BRANCH=${{ env.FLOWEDITOR_BRANCH }}
86
-
87
- - name : Build and push - Flows Varnish Image
88
- uses : docker/build-push-action@v3
89
- with :
90
- context : ./docker
91
- labels : |
92
- tag=${{env.TAG}}
93
- commit=${{env.COMMIT_SHA}}
94
- repository=${{env.IMAGE_SOURCE_URL}}
95
- file : docker/Dockerfile.varnish
96
- push : true
97
- tags : " ${{env.IMAGE_TAG}}-varnish"
98
- no-cache : true
99
- build-args : |
100
- BACKEND_ADDRESS=flows:8000
101
144
102
145
- name : Check out Kubernetes Manifests
103
146
uses : actions/checkout@master
104
147
with :
105
148
ref : main
149
+ # ref: feature/flows-cache
106
150
repository : " ${{ env.MANIFESTS_REPOSITORY }}"
107
151
token : " ${{ secrets.DEVOPS_GITHUB_PERMANENT_TOKEN }}"
108
152
path : ./kubernetes-manifests/
@@ -140,20 +184,13 @@ jobs:
140
184
)
141
185
echo "Old image version to compare: ${OLD_VERSION}<=${{env.VERSION}}"
142
186
if verlte "${OLD_VERSION}" "${VERSION}" || [[ ! "${OLD_VERSION}" =~ [0-9]+\.[0-9]+\.[0-9]+ ]] ; then
143
- echo 'New configurations for varnish:'
144
- new_configuration=$(
145
- cat "${e}/${{ env.MANIFESTS_PATCH_TARGET }}" \
146
- | jq '(..|select(.path == "/spec/template/spec/containers/1/image")?) += {value: "'"${{env.IMAGE_TAG}}"'-varnish"}'
147
- )
148
- echo "${new_configuration}"
149
- echo "${new_configuration}" > "${e}/${{ env.MANIFESTS_PATCH_TARGET }}"
150
187
echo 'New configurations for image flows:'
151
188
new_configuration=$(
152
- cat "${e}/${{ env.MANIFESTS_PATCH_TARGET1 }}" \
189
+ cat "${e}/${{ env.MANIFESTS_PATCH_TARGET }}" \
153
190
| jq '(..|select(.path == "/spec/template/spec/containers/0/image")?) += {value: "'"${{env.IMAGE_TAG}}"'"}'
154
191
)
155
192
echo "${new_configuration}"
156
- echo "${new_configuration}" > "${e}/${{ env.MANIFESTS_PATCH_TARGET1 }}"
193
+ echo "${new_configuration}" > "${e}/${{ env.MANIFESTS_PATCH_TARGET }}"
157
194
else
158
195
echo "Version in file is greater than build, skipping update yaml"
159
196
fi
@@ -167,4 +204,5 @@ jobs:
167
204
repository : " ${{ env.MANIFESTS_REPOSITORY }}"
168
205
directory : ./kubernetes-manifests/
169
206
branch : main
207
+ # branch: feature/flows-cache
170
208
message : " From Flows Build (Push Tag ${{ env.MANIFESTS_ENVIRONMENT }})"
0 commit comments