mirror of
https://gitee.com/actions-mirror/docker-login-action
synced 2024-11-23 20:30:41 +08:00
Display AWS CLI version
This commit is contained in:
parent
826c451920
commit
16b2f90c24
14
dist/index.js
generated
vendored
14
dist/index.js
generated
vendored
@ -1090,10 +1090,16 @@ function run() {
|
|||||||
const username = core.getInput('username');
|
const username = core.getInput('username');
|
||||||
const password = core.getInput('password', { required: true });
|
const password = core.getInput('password', { required: true });
|
||||||
if (yield ecr.isECR(registry)) {
|
if (yield ecr.isECR(registry)) {
|
||||||
|
yield exec.exec('aws', ['--version'], true).then(res => {
|
||||||
|
if (res.stderr != '' && !res.success) {
|
||||||
|
throw new Error(res.stderr);
|
||||||
|
}
|
||||||
|
core.info(`💡 Using ${res.stdout}`);
|
||||||
|
});
|
||||||
const ecrRegion = yield ecr.getRegion(registry);
|
const ecrRegion = yield ecr.getRegion(registry);
|
||||||
process.env.AWS_ACCESS_KEY_ID = username;
|
process.env.AWS_ACCESS_KEY_ID = username;
|
||||||
process.env.AWS_SECRET_ACCESS_KEY = password;
|
process.env.AWS_SECRET_ACCESS_KEY = password;
|
||||||
core.info(`Logging into AWS ECR region ${ecrRegion}...`);
|
core.info(`🔑 Logging into AWS ECR region ${ecrRegion}...`);
|
||||||
yield exec.exec('aws', ['ecr', 'get-login', '--region', ecrRegion, '--no-include-email'], true).then(res => {
|
yield exec.exec('aws', ['ecr', 'get-login', '--region', ecrRegion, '--no-include-email'], true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
@ -1107,6 +1113,12 @@ function run() {
|
|||||||
loginArgs.push('--username', username);
|
loginArgs.push('--username', username);
|
||||||
}
|
}
|
||||||
loginArgs.push(registry);
|
loginArgs.push(registry);
|
||||||
|
if (registry) {
|
||||||
|
core.info(`🔑 Logging into ${registry}...`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.info(`🔑 Logging into DockerHub...`);
|
||||||
|
}
|
||||||
yield exec.exec('docker', loginArgs, true).then(res => {
|
yield exec.exec('docker', loginArgs, true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
|
14
src/main.ts
14
src/main.ts
@ -19,11 +19,18 @@ async function run(): Promise<void> {
|
|||||||
const password: string = core.getInput('password', {required: true});
|
const password: string = core.getInput('password', {required: true});
|
||||||
|
|
||||||
if (await ecr.isECR(registry)) {
|
if (await ecr.isECR(registry)) {
|
||||||
|
await exec.exec('aws', ['--version'], true).then(res => {
|
||||||
|
if (res.stderr != '' && !res.success) {
|
||||||
|
throw new Error(res.stderr);
|
||||||
|
}
|
||||||
|
core.info(`💡 Using ${res.stdout}`);
|
||||||
|
});
|
||||||
|
|
||||||
const ecrRegion = await ecr.getRegion(registry);
|
const ecrRegion = await ecr.getRegion(registry);
|
||||||
process.env.AWS_ACCESS_KEY_ID = username;
|
process.env.AWS_ACCESS_KEY_ID = username;
|
||||||
process.env.AWS_SECRET_ACCESS_KEY = password;
|
process.env.AWS_SECRET_ACCESS_KEY = password;
|
||||||
|
|
||||||
core.info(`Logging into AWS ECR region ${ecrRegion}...`);
|
core.info(`🔑 Logging into AWS ECR region ${ecrRegion}...`);
|
||||||
await exec.exec('aws', ['ecr', 'get-login', '--region', ecrRegion, '--no-include-email'], true).then(res => {
|
await exec.exec('aws', ['ecr', 'get-login', '--region', ecrRegion, '--no-include-email'], true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
@ -37,6 +44,11 @@ async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
loginArgs.push(registry);
|
loginArgs.push(registry);
|
||||||
|
|
||||||
|
if (registry) {
|
||||||
|
core.info(`🔑 Logging into ${registry}...`);
|
||||||
|
} else {
|
||||||
|
core.info(`🔑 Logging into DockerHub...`);
|
||||||
|
}
|
||||||
await exec.exec('docker', loginArgs, true).then(res => {
|
await exec.exec('docker', loginArgs, true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
|
Loading…
Reference in New Issue
Block a user