Skip to content

Commit 753abb5

Browse files
committed
Add push-to-customers in build-docker-artifacts
1 parent 13ae9b9 commit 753abb5

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

.github/workflows/build-docker-artifacts-push-to-customer.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Push docker artifacts to customer (must be infrastructure-k8s)
1+
name: Push docker artifacts to customer (must be run in infrastructure-k8s)
22
run-name: Push ${{ inputs.repository }}:${{ inputs.image_tag }} docker artifacts to ${{ inputs.customer }}
33

44
on:
@@ -41,7 +41,7 @@ jobs:
4141
runs-on: ${{ inputs.runs_on || 'ubuntu-22.04' }}
4242

4343
steps:
44-
- name: Checkout repository (must be infrastructure-k8s)
44+
- name: Checkout repository (must be run in infrastructure-k8s)
4545
uses: actions/checkout@v4
4646
with:
4747
token: ${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}

.github/workflows/build-docker-artifacts-trigger-push-to-customer.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ on:
66
customers:
77
type: string
88
required: true
9-
description: Comma separated list of customers
9+
default: ""
10+
description: Comma separated list of customers. Leave empty to trigger for all customers.
1011
branch:
1112
type: string
1213
required: false
@@ -33,7 +34,7 @@ permissions:
3334

3435
jobs:
3536
get-customers:
36-
name: Trigger push docker artifacts to ${{ inputs.customers }}
37+
name: Trigger push docker artifacts to ${{ inputs.customers || 'all' }}
3738
runs-on: ${{ inputs.runs_on || 'ubuntu-22.04' }}
3839
outputs:
3940
result: ${{ steps.get-customers.outputs.result }}
@@ -44,14 +45,14 @@ jobs:
4445
with:
4546
ref: ${{ inputs.branch }}
4647
token: ${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
47-
48+
4849
- name: Checkout github-workflows repository
4950
uses: actions/checkout@v4
5051
with:
5152
repository: datavisyn/github-workflows
5253
ref: ${{ env.WORKFLOW_BRANCH }}
5354
path: ./tmp/github-workflows
54-
55+
5556
- name: Validate ./deploy/build/config.json
5657
shell: bash
5758
run: |
@@ -69,7 +70,9 @@ jobs:
6970
with:
7071
script: |
7172
const config = require('./deploy/build/config.json');
72-
const customers = process.env.CUSTOMERS.split(',');
73+
74+
const customers = process.env.CUSTOMERS ? process.env.CUSTOMERS.split(',') : Object.keys(config.customers);
75+
7376
const imageTagBranchName = "${{ github.ref }}".replace('refs/heads/', '').replace('refs/tags/', '').replace(/[^a-zA-Z0-9._-]/g, '-');
7477
7578
const result = customers.map((c) => ({
@@ -96,7 +99,7 @@ jobs:
9699
uses: datavisyn/github-action-trigger-workflow@v1
97100
with:
98101
owner: "datavisyn"
99-
repo: "infrastructure-k8s"
102+
repo: "infrastructure-k8s"
100103
github_token: ${{ secrets.DATAVISYN_BOT_REPO_TOKEN }}
101104
workflow_file_name: "push-docker-artifact-to-customer.yml"
102105
ref: "main"

.github/workflows/build-docker-artifacts.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ jobs:
105105
const result = {
106106
flavors,
107107
components: flattenedComponents,
108+
customers: Object.keys(config.customers).join(','),
108109
};
109110
console.log(result);
110111
return result;
@@ -232,7 +233,7 @@ jobs:
232233
exit 1 #exit execution due to docker image vulnerabilities
233234
fi
234235
235-
post-build:
236+
retag-images:
236237
name: Retag images of flavor ${{ matrix.flavor || 'default' }}
237238
needs: [get-flavors, build-flavors]
238239
strategy:
@@ -288,3 +289,22 @@ jobs:
288289
- name: Log out from Amazon ECR
289290
shell: bash
290291
run: docker logout ${{ steps.login-ecr.outputs.registry }}
292+
293+
push-to-customers:
294+
name: Push images to customers
295+
# if? When should we do this? Always? Only for certain branches? If so, how should we define that, in the config.json?
296+
needs: [retag-images, get-flavors]
297+
runs-on: ${{ inputs.runs_on || 'ubuntu-22.04' }}
298+
steps:
299+
- name: Checkout github-workflows repository
300+
uses: actions/checkout@v4
301+
with:
302+
repository: datavisyn/github-workflows
303+
ref: ${{ env.WORKFLOW_BRANCH }}
304+
path: ./tmp/github-workflows
305+
- name: Trigger push docker artifacts to ${{ fromJson(needs.get-flavors.outputs.result).customers }}
306+
uses: ./tmp/github-workflows/.github/workflows/build-docker-artifacts-trigger-push-to-customer
307+
with:
308+
customers: ${{ fromJson(needs.get-flavors.outputs.result).customers }}
309+
branch: ${{ inputs.branch }}
310+
runs_on: ${{ inputs.runs_on || 'ubuntu-22.04' }}

0 commit comments

Comments
 (0)