Skip to content

Commit 73098dc

Browse files
committed
INF-496 Remove the erroring docker login steps
1 parent a0c84eb commit 73098dc

File tree

1 file changed

+40
-168
lines changed

1 file changed

+40
-168
lines changed

.github/workflows/01-build-then-test.yml

Lines changed: 40 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -76,32 +76,6 @@ jobs:
7676
{"Key": "Name", "Value": "HEA-github-autoscale-runner"},
7777
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
7878
]
79-
ecr_login-test_branch:
80-
outputs:
81-
aws_access_key_id: ${{ steps.docker_login.outputs.aws_access_key_id }}
82-
aws_secret_access_key: ${{ steps.docker_login.outputs.aws_secret_access_key }}
83-
aws_session_token: ${{ steps.docker_login.outputs.aws_session_token }}
84-
aws_credential_expiration: ${{ steps.docker_login.outputs.aws_credential_expiration }}
85-
needs:
86-
- start-runner-test_branch # required to start the main job when the runner is ready
87-
runs-on: ${{ needs.start-runner-test_branch.outputs.label }} # run the job on the newly created runner
88-
steps:
89-
- name: Generate the ECR credentials
90-
id: docker_login
91-
run: |
92-
# authenticate to pull image that runs test jobs
93-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
94-
95-
# @TODO: "aws configure get" didn't work, replace package with awscli v2
96-
# and use "aws configure export-credentials"
97-
python3 -m pip install --user aws-export-credentials==0.18.0
98-
# set AWS vars to local environment
99-
eval $(~/.local/bin/aws-export-credentials --env-export)
100-
101-
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" >> $GITHUB_OUTPUT
102-
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >> $GITHUB_OUTPUT
103-
echo "aws_session_token=$AWS_SESSION_TOKEN" >> $GITHUB_OUTPUT
104-
echo "aws_credential_expiration=$AWS_CREDENTIAL_EXPIRATION" >> $GITHUB_OUTPUT
10579
10680
start-runner-test_keepdb:
10781
needs: lint
@@ -130,32 +104,6 @@ jobs:
130104
{"Key": "Name", "Value": "HEA-github-autoscale-runner"},
131105
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
132106
]
133-
ecr_login-test_keepdb:
134-
outputs:
135-
aws_access_key_id: ${{ steps.docker_login.outputs.aws_access_key_id }}
136-
aws_secret_access_key: ${{ steps.docker_login.outputs.aws_secret_access_key }}
137-
aws_session_token: ${{ steps.docker_login.outputs.aws_session_token }}
138-
aws_credential_expiration: ${{ steps.docker_login.outputs.aws_credential_expiration }}
139-
needs:
140-
- start-runner-test_keepdb # required to start the main job when the runner is ready
141-
runs-on: ${{ needs.start-runner-test_keepdb.outputs.label }} # run the job on the newly created runner
142-
steps:
143-
- name: Generate the ECR credentials
144-
id: docker_login
145-
run: |
146-
# authenticate to pull image that runs test jobs
147-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
148-
149-
# @TODO: "aws configure get" didn't work, replace package with awscli v2
150-
# and use "aws configure export-credentials"
151-
python3 -m pip install --user aws-export-credentials==0.18.0
152-
# set AWS vars to local environment
153-
eval $(~/.local/bin/aws-export-credentials --env-export)
154-
155-
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" >> $GITHUB_OUTPUT
156-
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >> $GITHUB_OUTPUT
157-
echo "aws_session_token=$AWS_SESSION_TOKEN" >> $GITHUB_OUTPUT
158-
echo "aws_credential_expiration=$AWS_CREDENTIAL_EXPIRATION" >> $GITHUB_OUTPUT
159107
160108
start-runner-test_main:
161109
if: github.ref == 'refs/heads/main'
@@ -185,32 +133,6 @@ jobs:
185133
{"Key": "Name", "Value": "HEA-github-autoscale-runner"},
186134
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
187135
]
188-
ecr_login-test_main:
189-
outputs:
190-
aws_access_key_id: ${{ steps.docker_login.outputs.aws_access_key_id }}
191-
aws_secret_access_key: ${{ steps.docker_login.outputs.aws_secret_access_key }}
192-
aws_session_token: ${{ steps.docker_login.outputs.aws_session_token }}
193-
aws_credential_expiration: ${{ steps.docker_login.outputs.aws_credential_expiration }}
194-
needs:
195-
- start-runner-test_main # required to start the main job when the runner is ready
196-
runs-on: ${{ needs.start-runner-test_main.outputs.label }} # run the job on the newly created runner
197-
steps:
198-
- name: Generate the ECR credentials
199-
id: docker_login
200-
run: |
201-
# authenticate to pull image that runs test jobs
202-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
203-
204-
# @TODO: "aws configure get" didn't work, replace package with awscli v2
205-
# and use "aws configure export-credentials"
206-
python3 -m pip install --user aws-export-credentials==0.18.0
207-
# set AWS vars to local environment
208-
eval $(~/.local/bin/aws-export-credentials --env-export)
209-
210-
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" >> $GITHUB_OUTPUT
211-
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >> $GITHUB_OUTPUT
212-
echo "aws_session_token=$AWS_SESSION_TOKEN" >> $GITHUB_OUTPUT
213-
echo "aws_credential_expiration=$AWS_CREDENTIAL_EXPIRATION" >> $GITHUB_OUTPUT
214136
215137
start-runner-test_tag:
216138
if: startsWith(github.ref, 'refs/tags/')
@@ -240,32 +162,6 @@ jobs:
240162
{"Key": "Name", "Value": "HEA-github-autoscale-runner"},
241163
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
242164
]
243-
ecr_login-test_tag:
244-
outputs:
245-
aws_access_key_id: ${{ steps.docker_login.outputs.aws_access_key_id }}
246-
aws_secret_access_key: ${{ steps.docker_login.outputs.aws_secret_access_key }}
247-
aws_session_token: ${{ steps.docker_login.outputs.aws_session_token }}
248-
aws_credential_expiration: ${{ steps.docker_login.outputs.aws_credential_expiration }}
249-
needs:
250-
- start-runner-test_tag # required to start the main job when the runner is ready
251-
runs-on: ${{ needs.start-runner-test_tag.outputs.label }} # run the job on the newly created runner
252-
steps:
253-
- name: Generate the ECR credentials
254-
id: docker_login
255-
run: |
256-
# authenticate to pull image that runs test jobs
257-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
258-
259-
# @TODO: "aws configure get" didn't work, replace package with awscli v2
260-
# and use "aws configure export-credentials"
261-
python3 -m pip install --user aws-export-credentials==0.18.0
262-
# set AWS vars to local environment
263-
eval $(~/.local/bin/aws-export-credentials --env-export)
264-
265-
echo "aws_access_key_id=$AWS_ACCESS_KEY_ID" >> $GITHUB_OUTPUT
266-
echo "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" >> $GITHUB_OUTPUT
267-
echo "aws_session_token=$AWS_SESSION_TOKEN" >> $GITHUB_OUTPUT
268-
echo "aws_credential_expiration=$AWS_CREDENTIAL_EXPIRATION" >> $GITHUB_OUTPUT
269165
270166
test_branch:
271167
if: ${{ !(startsWith(github.ref, 'refs/tags/')) && !(github.ref == 'refs/heads/main') }}
@@ -276,7 +172,6 @@ jobs:
276172
runs-on: ${{ needs.start-runner-test_branch.outputs.label }} # run the job on the newly created runner
277173
needs:
278174
- start-runner-test_branch
279-
- ecr_login-test_branch
280175
container:
281176
image: 888016039450.dkr.ecr.us-east-1.amazonaws.com/inf/docker:latest
282177
defaults:
@@ -296,26 +191,20 @@ jobs:
296191
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml:docker-compose.utils.yml
297192
CI_REGISTRY_IMAGE: "888016039450.dkr.ecr.us-east-1.amazonaws.com/hea"
298193
BUILD_IMAGES: "app db"
299-
AWS_ACCESS_KEY_ID: ${{ needs.ecr_login-test_branch.outputs.aws_access_key_id }}
300-
AWS_SECRET_ACCESS_KEY: ${{ needs.ecr_login-test_branch.outputs.aws_secret_access_key }}
301-
AWS_SESSION_TOKEN: ${{ needs.ecr_login-test_branch.outputs.aws_session_token }}
302-
AWS_CREDENTIAL_EXPIRATION: ${{ needs.ecr_login-test_branch.outputs.aws_credential_expiration }}
303194

304195
steps:
305-
- name: "Authenticate with ECR"
306-
run: |
307-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
308-
196+
- name: Login to Amazon ECR
197+
id: login-ecr
198+
uses: aws-actions/amazon-ecr-login@v2
199+
with:
200+
mask-password: 'true'
309201
# Docker hub is rate-limiting unauthenticated users, so we have to
310202
# authenticate: https://www.docker.com/increase-rate-limits
311-
- name: "Log in to Docker hub"
312-
run: |
313-
echo Using registry image ${CI_REGISTRY_IMAGE}
314-
# log in to ECR
315-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
316-
317-
# log in to Docker hub
318-
echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login --username=${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
203+
- name: Login to the DockerHub Container Registry
204+
uses: docker/login-action@v3
205+
with:
206+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
207+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
319208
- name: "Pull previous images to speed up builds"
320209
run: |
321210
for SERVICE in ${BUILD_IMAGES}; do (docker pull ${CI_REGISTRY_IMAGE}/${SERVICE}:edge | grep -i -e 'Pulling from' -e Digest -e Status -e Error) || true; done
@@ -426,7 +315,6 @@ jobs:
426315
runs-on: ${{ needs.start-runner-test_keepdb.outputs.label }} # run the job on the newly created runner
427316
needs:
428317
- start-runner-test_keepdb
429-
- ecr_login-test_keepdb
430318
container:
431319
image: 888016039450.dkr.ecr.us-east-1.amazonaws.com/inf/docker:latest
432320
defaults:
@@ -446,26 +334,20 @@ jobs:
446334
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml:docker-compose.utils.yml
447335
CI_REGISTRY_IMAGE: "888016039450.dkr.ecr.us-east-1.amazonaws.com/hea"
448336
BUILD_IMAGES: "app db"
449-
AWS_ACCESS_KEY_ID: ${{ needs.ecr_login-test_keepdb.outputs.aws_access_key_id }}
450-
AWS_SECRET_ACCESS_KEY: ${{ needs.ecr_login-test_keepdb.outputs.aws_secret_access_key }}
451-
AWS_SESSION_TOKEN: ${{ needs.ecr_login-test_keepdb.outputs.aws_session_token }}
452-
AWS_CREDENTIAL_EXPIRATION: ${{ needs.ecr_login-test_keepdb.outputs.aws_credential_expiration }}
453337

454338
steps:
455-
- name: "Authenticate with ECR"
456-
run: |
457-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
458-
339+
- name: Login to Amazon ECR
340+
id: login-ecr
341+
uses: aws-actions/amazon-ecr-login@v2
342+
with:
343+
mask-password: 'true'
459344
# Docker hub is rate-limiting unauthenticated users, so we have to
460345
# authenticate: https://www.docker.com/increase-rate-limits
461-
- name: "Log in to Docker hub"
462-
run: |
463-
echo Using registry image ${CI_REGISTRY_IMAGE}
464-
# log in to ECR
465-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
466-
467-
# log in to Docker hub
468-
echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login --username=${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
346+
- name: Login to the DockerHub Container Registry
347+
uses: docker/login-action@v3
348+
with:
349+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
350+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
469351
- name: "Pull previous images to speed up builds"
470352
run: |
471353
for SERVICE in ${BUILD_IMAGES}; do (docker pull ${CI_REGISTRY_IMAGE}/${SERVICE}:edge | grep -i -e 'Pulling from' -e Digest -e Status -e Error) || true; done
@@ -558,7 +440,6 @@ jobs:
558440
runs-on: ${{ needs.start-runner-test_main.outputs.label }} # run the job on the newly created runner
559441
needs:
560442
- start-runner-test_main
561-
- ecr_login-test_main
562443
container:
563444
image: 888016039450.dkr.ecr.us-east-1.amazonaws.com/inf/docker:latest
564445
defaults:
@@ -578,26 +459,20 @@ jobs:
578459
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml:docker-compose.utils.yml
579460
CI_REGISTRY_IMAGE: "888016039450.dkr.ecr.us-east-1.amazonaws.com/hea"
580461
BUILD_IMAGES: "app db"
581-
AWS_ACCESS_KEY_ID: ${{ needs.ecr_login-test_main.outputs.aws_access_key_id }}
582-
AWS_SECRET_ACCESS_KEY: ${{ needs.ecr_login-test_main.outputs.aws_secret_access_key }}
583-
AWS_SESSION_TOKEN: ${{ needs.ecr_login-test_main.outputs.aws_session_token }}
584-
AWS_CREDENTIAL_EXPIRATION: ${{ needs.ecr_login-test_main.outputs.aws_credential_expiration }}
585462

586463
steps:
587-
- name: "Authenticate with ECR"
588-
run: |
589-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
590-
464+
- name: Login to Amazon ECR
465+
id: login-ecr
466+
uses: aws-actions/amazon-ecr-login@v2
467+
with:
468+
mask-password: 'true'
591469
# Docker hub is rate-limiting unauthenticated users, so we have to
592470
# authenticate: https://www.docker.com/increase-rate-limits
593-
- name: "Log in to Docker hub"
594-
run: |
595-
echo Using registry image ${CI_REGISTRY_IMAGE}
596-
# log in to ECR
597-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
598-
599-
# log in to Docker hub
600-
echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login --username=${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
471+
- name: Login to the DockerHub Container Registry
472+
uses: docker/login-action@v3
473+
with:
474+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
475+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
601476
- name: "Pull previous images to speed up builds"
602477
run: |
603478
echo Using registry image ${CI_REGISTRY_IMAGE}
@@ -693,7 +568,6 @@ jobs:
693568
runs-on: ${{ needs.start-runner-test_tag.outputs.label }} # run the job on the newly created runner
694569
needs:
695570
- start-runner-test_tag
696-
- ecr_login-test_tag
697571
container:
698572
image: 888016039450.dkr.ecr.us-east-1.amazonaws.com/inf/docker:latest
699573
defaults:
@@ -713,22 +587,20 @@ jobs:
713587
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml:docker-compose.utils.yml
714588
CI_REGISTRY_IMAGE: "888016039450.dkr.ecr.us-east-1.amazonaws.com/hea"
715589
BUILD_IMAGES: "app db"
716-
AWS_ACCESS_KEY_ID: ${{ needs.ecr_login-test_tag.outputs.aws_access_key_id }}
717-
AWS_SECRET_ACCESS_KEY: ${{ needs.ecr_login-test_tag.outputs.aws_secret_access_key }}
718-
AWS_SESSION_TOKEN: ${{ needs.ecr_login-test_tag.outputs.aws_session_token }}
719-
AWS_CREDENTIAL_EXPIRATION: ${{ needs.ecr_login-test_tag.outputs.aws_credential_expiration }}
720590

721591
steps:
722-
- name: "Authenticate with ECR"
723-
run: |
724-
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
725-
592+
- name: Login to Amazon ECR
593+
id: login-ecr
594+
uses: aws-actions/amazon-ecr-login@v2
595+
with:
596+
mask-password: 'true'
726597
# Docker hub is rate-limiting unauthenticated users, so we have to
727598
# authenticate: https://www.docker.com/increase-rate-limits
728-
- name: "Log in to Docker hub"
729-
run: |
730-
# log in to Docker hub
731-
echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login --username=${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
599+
- name: Login to the DockerHub Container Registry
600+
uses: docker/login-action@v3
601+
with:
602+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
603+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
732604
- uses: "actions/checkout@v4"
733605
with:
734606
ssh-key: ${{ secrets.GIT_SSH_PRIVATE_KEY }}

0 commit comments

Comments
 (0)