@@ -45,13 +45,48 @@ jobs:
45
45
echo '⏯ Dockerfile changed'
46
46
echo "::set-output name=result::true"
47
47
else
48
- echo '⏭ Dockerfile not changed'
49
- echo "::set-output name=result::false"
48
+ if grep '.github/workflows/docker-images.yml' <<< "${changed}" ; then
49
+ echo '⏯ docker-images workflow changed'
50
+ echo "::set-output name=result::true"
51
+ else
52
+ echo '⏭ Dockerfile not changed'
53
+ echo "::set-output name=result::false"
54
+ fi
50
55
fi
51
56
fi
52
57
58
+ # Check if federation into AWS is configured. This is necessary because
59
+ # GitHub does not interpret ${{ secret.FOO }} within `if:` conditions...
60
+ # See: https://github.com/actions/runner/issues/520
61
+ - name : Check AWS federation configuration
62
+ id : federate_to_aws
63
+ if : steps.should-run.outputs.result == 'true'
64
+ run : |-
65
+ if [[ "${{ secrets.AWS_ROLE_TO_ASSUME }}" != "" ]]; then
66
+ echo "🔑 Federation into AWS is possible (AWS_ROLE_TO_ASSUME is available)"
67
+ echo "::set-output name=enabled::true"
68
+ else
69
+ echo "❌ Federation into AWS is disabled (no AWS_ROLE_TO_ASSUME secret found)"
70
+ echo "::set-output name=enabled::false"
71
+ fi
72
+
73
+ # Federate into the PR Validation AWS Account
74
+ - name : Federate into AWS
75
+ if : steps.should-run.outputs.result == 'true' && steps.federate_to_aws.outputs.enabled == 'true'
76
+ uses : aws-actions/configure-aws-credentials@v1
77
+ with :
78
+ role-to-assume : ${{ secrets.AWS_ROLE_TO_ASSUME }}
79
+ aws-region : us-east-1
80
+
81
+ # Login to ECR Public registry, so we don't get throttled at 1 TPS
82
+ - name : Login to ECR Public
83
+ if : steps.should-run.outputs.result == 'true' && steps.federate_to_aws.outputs.enabled == 'true'
84
+ run : |-
85
+ aws ecr-public get-login-password --region=us-east-1 \
86
+ | docker login --username AWS --password-stdin public.ecr.aws
87
+
53
88
# We only authenticate to Docker on the 'aws/jsii' repo, as forks will not have the secret
54
- - name : Login to Docker
89
+ - name : Login to Docker Hub
55
90
if : steps.should-run.outputs.result == 'true' && github.repository == 'aws/jsii'
56
91
# The DOCKER_CREDENTIALS secret is expected to contain a username:token pair
57
92
run : |-
@@ -70,6 +105,12 @@ jobs:
70
105
id : buildx
71
106
if : steps.should-run.outputs.result == 'true'
72
107
uses : docker/setup-buildx-action@v2
108
+ with :
109
+ # Disable parallelism because IO contention makes it too slow on GitHub
110
+ # workers...
111
+ config-inline : |-
112
+ [worker.oci]
113
+ max-parallelism = 1
73
114
74
115
# We only restore GH cache if we are not going to publish the result (i.e: PR validation)
75
116
- name : Set up layer cache
85
126
# 1 pull per second from ECR Public
86
127
- name : Jitter the start time to avoid ECR Public throttling
87
128
id : sleep-start
88
- if : steps.should-run.outputs.result == 'true'
129
+ if : steps.should-run.outputs.result == 'true' && steps.federate_to_aws.outputs.enabled != true
89
130
run : |-
90
131
sleep $((RANDOM % 60))
91
132
@@ -111,27 +152,12 @@ jobs:
111
152
-f superchain/Dockerfile \
112
153
.
113
154
114
- # Testing sequentially, because in parallel it's too slow due to IO contention
115
- - name : Test Image (AMD64)
116
- if : steps.should-run.outputs.result == 'true'
117
- run : |-
118
- docker buildx build \
119
- --builder ${{ steps.buildx.outputs.name }} \
120
- --platform linux/amd64 \
121
- --target superchain \
122
- --cache-from type=local,src=/tmp/.buildx-cache \
123
- --cache-to type=local,dest=/tmp/.buildx-cache \
124
- --build-arg BUILD_TIMESTAMP="${{ steps.build-time.outputs.value }}" \
125
- --build-arg COMMIT_ID='${{ github.sha }}' \
126
- --build-arg NODE_MAJOR_VERSION=${{ matrix.node }} \
127
- -f superchain/Dockerfile \
128
- .
129
- - name : Test Image (ARM64)
155
+ - name : Test Image
130
156
if : steps.should-run.outputs.result == 'true'
131
157
run : |-
132
158
docker buildx build \
133
159
--builder ${{ steps.buildx.outputs.name }} \
134
- --platform linux/arm64 \
160
+ --platform linux/amd64,linux/ arm64 \
135
161
--target superchain \
136
162
--cache-from type=local,src=/tmp/.buildx-cache \
137
163
--cache-to type=local,dest=/tmp/.buildx-cache \
0 commit comments