Skip to content

Commit

Permalink
Fix deprecated aws-cli login command
Browse files Browse the repository at this point in the history
get-login -> get-login-password
  • Loading branch information
brew committed Mar 5, 2021
1 parent b5d6e77 commit d541831
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Docker Build & Push Action

<p><a href="https://github.com/fourteenfish/docker-build-push"><img alt="GitHub Actions status" src="https://github.com/fourteenfish/docker-build-push/workflows/Tests/badge.svg"></a></p>

Builds a Docker image and pushes it to the private registry of your choosing.
Expand Down Expand Up @@ -94,7 +95,7 @@ By default, if you do not pass a `tag` input this action will use an algorithm b
| /refs/heads/master | 1234567 | master-1234567 | |
| /refs/heads/SOME-feature | 1234567 | some-feature-1234567 | |

Tags prepended with 'relsease', such as `release/myapp-v1.0.0`, will return a Docker tag of just the part after the last dash, eg. v1.0.0. This can be useful when you have a 'mono-repository' containing multiple apps, but want to trigger github actions for specific apps. So, a github action for 'myapp' can be set up to trigger only on tags that filter for that app:
Tags prepended with 'release', such as `release/myapp-v1.0.0`, will return a Docker tag of just the part after the last dash, eg. v1.0.0. This can be useful when you have a 'mono-repository' containing multiple apps, but want to trigger github actions for specific apps. So, a github action for 'myapp' can be set up to trigger only on tags that filter for that app:

```yaml
on:
Expand Down
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,9 @@ const login = () => {
if (isEcr(registry)) {
const region = getRegion(registry);
core.info(`Logging into ECR region ${region}...`);
cp.execSync(`$(aws ecr get-login --region ${region} --no-include-email)`);
cp.execSync(
`aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${registry}`
);
} else if (username && password) {
core.info(`Logging into Docker registry ${registry}...`);
cp.execSync(`docker login -u ${username} --password-stdin ${registry}`, {
Expand Down
4 changes: 3 additions & 1 deletion src/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ const login = () => {
if (isEcr(registry)) {
const region = getRegion(registry);
core.info(`Logging into ECR region ${region}...`);
cp.execSync(`$(aws ecr get-login --region ${region} --no-include-email)`);
cp.execSync(
`aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${registry}`
);
} else if (username && password) {
core.info(`Logging into Docker registry ${registry}...`);
cp.execSync(`docker login -u ${username} --password-stdin ${registry}`, {
Expand Down
4 changes: 3 additions & 1 deletion tests/docker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ describe('core and cp methods', () => {

docker.login();

expect(cp.execSync).toHaveBeenCalledWith(`$(aws ecr get-login --region us-east-1 --no-include-email)`);
expect(cp.execSync).toHaveBeenCalledWith(
`aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${registry}`
);
});

test("returns undefined if empty login and doesn't execute command", () => {
Expand Down

0 comments on commit d541831

Please sign in to comment.