Skip to content

Commit 53ed716

Browse files
committed
Use private fields to allow overriding
1 parent 6544c0c commit 53ed716

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

.github/workflows/docker-build-simple.libsonnet

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,30 @@
33
// Docker manifest #{name}/Dockerfile
44
// ECR repository: #{name}
55

6-
local runnersMap = {
7-
'linux/amd64': 'ubuntu-24.04',
8-
'linux/arm64': 'ubuntu-24.04-arm',
9-
};
6+
function(name, region='ap-northeast-1', platforms=['linux/arm64']) {
7+
common:: {
8+
setupSteps: [
9+
{ uses: 'docker/setup-buildx-action@v3' },
10+
{
11+
uses: 'aws-actions/configure-aws-credentials@v4',
12+
with: {
13+
'aws-region': region,
14+
'role-to-assume': 'arn:aws:iam::005216166247:role/GhaDockerPush',
15+
'role-skip-session-tagging': true,
16+
},
17+
},
18+
{
19+
uses: 'aws-actions/amazon-ecr-login@v2',
20+
id: 'login-ecr',
21+
},
22+
],
1023

11-
local setupSteps = function(region) [
12-
{ uses: 'docker/setup-buildx-action@v3' },
13-
{
14-
uses: 'aws-actions/configure-aws-credentials@v4',
15-
with: {
16-
'aws-region': region,
17-
'role-to-assume': 'arn:aws:iam::005216166247:role/GhaDockerPush',
18-
'role-skip-session-tagging': true,
24+
runnersMap: {
25+
'linux/amd64': 'ubuntu-24.04',
26+
'linux/arm64': 'ubuntu-24.04-arm',
1927
},
2028
},
21-
{
22-
uses: 'aws-actions/amazon-ecr-login@v2',
23-
id: 'login-ecr',
24-
},
25-
];
2629

27-
function(name, region='ap-northeast-1', platforms=['linux/arm64']) {
2830
name: std.format('docker-%s', name),
2931
on: {
3032
push: {
@@ -42,14 +44,14 @@ function(name, region='ap-northeast-1', platforms=['linux/arm64']) {
4244
include: std.map(function(platform) {
4345
key: std.strReplace(platform, '/', '-'), // for artifact name
4446
platform: platform,
45-
runner: runnersMap[platform],
47+
runner: $.common.runnersMap[platform],
4648
}, platforms),
4749
},
4850
},
4951
name: 'build (${{ matrix.platform }})',
5052
'runs-on': '${{ matrix.runner }}',
5153
permissions: { 'id-token': 'write', contents: 'read' },
52-
steps: setupSteps(region) + [
54+
steps: $.common.setupSteps + [
5355
{
5456
uses: 'docker/build-push-action@v6',
5557
id: 'build-push',
@@ -87,7 +89,7 @@ function(name, region='ap-northeast-1', platforms=['linux/arm64']) {
8789
'runs-on': 'ubuntu-latest',
8890
needs: ['build'],
8991
permissions: { 'id-token': 'write' },
90-
steps: setupSteps(region) + [
92+
steps: $.common.setupSteps + [
9193
{
9294
name: 'Download digests',
9395
uses: 'actions/download-artifact@v4',

0 commit comments

Comments
 (0)