-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__test-workflow-docker-build-images-building.yml
More file actions
87 lines (77 loc) · 2.97 KB
/
Copy path__test-workflow-docker-build-images-building.yml
File metadata and controls
87 lines (77 loc) · 2.97 KB
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
---
name: Test for "docker-build-images" workflow - Building
run-name: Test for "docker-build-images" workflow - Building
on: # yamllint disable-line rule:truthy
workflow_call:
permissions: {}
# jscpd:ignore-start
jobs:
act-build-images-args-secrets:
name: Arrange - Build with args, secrets
uses: ./.github/workflows/docker-build-images.yml
permissions:
contents: read
id-token: write
issues: read
packages: write
pull-requests: read
secrets:
oci-registry-password: ${{ secrets.GITHUB_TOKEN }}
build-secrets: |
SECRET_TEST=test-secret
SECRET_ANOTHER_TEST=another-test-secret
build-secret-github-app-key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }}
with:
images: |
[
{
"name": "test-build-args-secrets",
"context": ".",
"target": "test",
"dockerfile": "./tests/application/Dockerfile",
"platforms": ["linux/amd64"],
"build-args": {
"BUILD_RUN_ID": "${{ github.run_id }}",
"BUILD_ARG_TEST": "test-arg",
"BUILD_ARG_ANOTHER_TEST": "another-test-arg"
},
"secret-envs": {
"SECRET_ENV_TEST": "GITHUB_ACTION",
"SECRET_ENV_ANOTHER_TEST": "GITHUB_JOB"
}
}
]
build-secret-github-app-client-id: ${{ vars.CI_BOT_APP_CLIENT_ID }}
build-secret-github-app-token-env: |
SECRET_ENV_GITHUB_APP_TOKEN_1
SECRET_ENV_GITHUB_APP_TOKEN_2
assert-build-args-secrets:
name: Assert - Build with args, secrets
needs: act-build-images-args-secrets
runs-on: "ubuntu-latest"
steps:
- name: Check built images ouput
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
BUILT_IMAGES_OUTPUT: ${{ needs.act-build-images-args-secrets.outputs.built-images }}
with:
script: |
const assert = require("assert");
const builtImagesOutput = process.env.BUILT_IMAGES_OUTPUT;
assert(builtImagesOutput.length, `"built-images" output is empty`);
// Check if is valid Json
let builtImages = null;
try {
builtImages = JSON.parse(builtImagesOutput);
} catch (error) {
throw new Error(`"built-images" output is not a valid JSON: ${error}`);
}
const expectedCreatedImages = [
"test-build-args-secrets"
];
assert(typeof builtImages === "object" && !Array.isArray(builtImages), `"built-images" output is not an object`);
assert.equal(Object.keys(builtImages).length, expectedCreatedImages.length, `"built-images" output does not contain ${expectedCreatedImages.length} images`);
for (const image of expectedCreatedImages) {
assert(builtImages[image], `"built-images" output does not contain "${image}" image`);
}
# jscpd:ignore-end