mirror of
https://github.com/docker/login-action.git
synced 2024-12-23 03:25:30 +00:00
Remove os limitation
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
4b206288bd
commit
7439f8b467
BIN
.github/docker-login.png
vendored
BIN
.github/docker-login.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 5 KiB After Width: | Height: | Size: 4.3 KiB |
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
|
@ -10,6 +10,24 @@ on:
|
||||||
- 'releases/v*'
|
- 'releases/v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
stop-docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
-
|
||||||
|
name: Stop docker
|
||||||
|
run: |
|
||||||
|
sudo systemctl stop docker
|
||||||
|
-
|
||||||
|
name: Login to GitHub Container Registry
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
dind:
|
dind:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
|
|
10
README.md
10
README.md
|
@ -8,11 +8,6 @@
|
||||||
|
|
||||||
GitHub Action to login against a Docker registry.
|
GitHub Action to login against a Docker registry.
|
||||||
|
|
||||||
> :bulb: See also:
|
|
||||||
> * [setup-buildx](https://github.com/docker/setup-buildx-action) action
|
|
||||||
> * [setup-qemu](https://github.com/docker/setup-qemu-action) action
|
|
||||||
> * [build-push](https://github.com/docker/build-push-action) action
|
|
||||||
|
|
||||||
![Screenshot](.github/docker-login.png)
|
![Screenshot](.github/docker-login.png)
|
||||||
|
|
||||||
___
|
___
|
||||||
|
@ -32,7 +27,6 @@ ___
|
||||||
* [Customizing](#customizing)
|
* [Customizing](#customizing)
|
||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
|
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
|
||||||
* [Limitation](#limitation)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -433,7 +427,3 @@ updates:
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "daily"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Limitation
|
|
||||||
|
|
||||||
This action is only available for Linux [virtual environments](https://help.github.com/en/articles/virtual-environments-for-github-actions#supported-virtual-environments-and-hardware-resources).
|
|
||||||
|
|
|
@ -6,17 +6,6 @@ import * as stateHelper from '../src/state-helper';
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
test('errors when not run on linux platform', async () => {
|
|
||||||
const platSpy = jest.spyOn(osm, 'platform');
|
|
||||||
platSpy.mockImplementation(() => 'netbsd');
|
|
||||||
|
|
||||||
const coreSpy: jest.SpyInstance = jest.spyOn(core, 'setFailed');
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(coreSpy).toHaveBeenCalledWith('Only supported on linux platform');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('errors without username and password', async () => {
|
test('errors without username and password', async () => {
|
||||||
const platSpy = jest.spyOn(osm, 'platform');
|
const platSpy = jest.spyOn(osm, 'platform');
|
||||||
platSpy.mockImplementation(() => 'linux');
|
platSpy.mockImplementation(() => 'linux');
|
||||||
|
|
26
dist/index.js
generated
vendored
26
dist/index.js
generated
vendored
|
@ -497,18 +497,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.run = void 0;
|
exports.run = void 0;
|
||||||
const os = __importStar(__webpack_require__(87));
|
|
||||||
const core = __importStar(__webpack_require__(186));
|
const core = __importStar(__webpack_require__(186));
|
||||||
const context_1 = __webpack_require__(842);
|
const context = __importStar(__webpack_require__(842));
|
||||||
const docker = __importStar(__webpack_require__(758));
|
const docker = __importStar(__webpack_require__(758));
|
||||||
const stateHelper = __importStar(__webpack_require__(647));
|
const stateHelper = __importStar(__webpack_require__(647));
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
if (os.platform() !== 'linux') {
|
const { registry, username, password, logout } = context.getInputs();
|
||||||
throw new Error('Only supported on linux platform');
|
|
||||||
}
|
|
||||||
const { registry, username, password, logout } = context_1.getInputs();
|
|
||||||
stateHelper.setRegistry(registry);
|
stateHelper.setRegistry(registry);
|
||||||
stateHelper.setLogout(logout);
|
stateHelper.setLogout(logout);
|
||||||
yield docker.login(registry, username, password);
|
yield docker.login(registry, username, password);
|
||||||
|
@ -3069,16 +3065,16 @@ function loginStandard(registry, username, password) {
|
||||||
loginArgs.push('--username', username);
|
loginArgs.push('--username', username);
|
||||||
loginArgs.push(registry);
|
loginArgs.push(registry);
|
||||||
if (registry) {
|
if (registry) {
|
||||||
core.info(`🔑 Logging into ${registry}...`);
|
core.info(`Logging into ${registry}...`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`🔑 Logging into Docker Hub...`);
|
core.info(`Logging into Docker Hub...`);
|
||||||
}
|
}
|
||||||
yield execm.exec('docker', loginArgs, true, password).then(res => {
|
yield execm.exec('docker', loginArgs, true, password).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
}
|
}
|
||||||
core.info('🎉 Login Succeeded!');
|
core.info(`Login Succeeded!`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3090,26 +3086,26 @@ function loginECR(registry, username, password) {
|
||||||
const region = yield aws.getRegion(registry);
|
const region = yield aws.getRegion(registry);
|
||||||
const accountIDs = yield aws.getAccountIDs(registry);
|
const accountIDs = yield aws.getAccountIDs(registry);
|
||||||
if (yield aws.isPubECR(registry)) {
|
if (yield aws.isPubECR(registry)) {
|
||||||
core.info(`💡 AWS Public ECR detected with ${region} region`);
|
core.info(`AWS Public ECR detected with ${region} region`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`💡 AWS ECR detected with ${region} region`);
|
core.info(`AWS ECR detected with ${region} region`);
|
||||||
}
|
}
|
||||||
process.env.AWS_ACCESS_KEY_ID = username || process.env.AWS_ACCESS_KEY_ID;
|
process.env.AWS_ACCESS_KEY_ID = username || process.env.AWS_ACCESS_KEY_ID;
|
||||||
process.env.AWS_SECRET_ACCESS_KEY = password || process.env.AWS_SECRET_ACCESS_KEY;
|
process.env.AWS_SECRET_ACCESS_KEY = password || process.env.AWS_SECRET_ACCESS_KEY;
|
||||||
core.info(`⬇️ Retrieving docker login command through AWS CLI ${cliVersion} (${cliPath})...`);
|
core.info(`Retrieving docker login command through AWS CLI ${cliVersion} (${cliPath})...`);
|
||||||
const loginCmds = yield aws.getDockerLoginCmds(cliVersion, registry, region, accountIDs);
|
const loginCmds = yield aws.getDockerLoginCmds(cliVersion, registry, region, accountIDs);
|
||||||
core.info(`🔑 Logging into ${registry}...`);
|
core.info(`Logging into ${registry}...`);
|
||||||
loginCmds.forEach((loginCmd, index) => {
|
loginCmds.forEach((loginCmd, index) => {
|
||||||
execm.exec(loginCmd, [], true).then(res => {
|
execm.exec(loginCmd, [], true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
}
|
}
|
||||||
if (loginCmds.length > 1) {
|
if (loginCmds.length > 1) {
|
||||||
core.info(`🎉 Login Succeeded! (${index}/${loginCmds.length})`);
|
core.info(`Login Succeeded! (${index}/${loginCmds.length})`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info('🎉 Login Succeeded!');
|
core.info('Login Succeeded!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,15 +28,15 @@ export async function loginStandard(registry: string, username: string, password
|
||||||
loginArgs.push(registry);
|
loginArgs.push(registry);
|
||||||
|
|
||||||
if (registry) {
|
if (registry) {
|
||||||
core.info(`🔑 Logging into ${registry}...`);
|
core.info(`Logging into ${registry}...`);
|
||||||
} else {
|
} else {
|
||||||
core.info(`🔑 Logging into Docker Hub...`);
|
core.info(`Logging into Docker Hub...`);
|
||||||
}
|
}
|
||||||
await execm.exec('docker', loginArgs, true, password).then(res => {
|
await execm.exec('docker', loginArgs, true, password).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
}
|
}
|
||||||
core.info('🎉 Login Succeeded!');
|
core.info(`Login Succeeded!`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,27 +47,27 @@ export async function loginECR(registry: string, username: string, password: str
|
||||||
const accountIDs = await aws.getAccountIDs(registry);
|
const accountIDs = await aws.getAccountIDs(registry);
|
||||||
|
|
||||||
if (await aws.isPubECR(registry)) {
|
if (await aws.isPubECR(registry)) {
|
||||||
core.info(`💡 AWS Public ECR detected with ${region} region`);
|
core.info(`AWS Public ECR detected with ${region} region`);
|
||||||
} else {
|
} else {
|
||||||
core.info(`💡 AWS ECR detected with ${region} region`);
|
core.info(`AWS ECR detected with ${region} region`);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.env.AWS_ACCESS_KEY_ID = username || process.env.AWS_ACCESS_KEY_ID;
|
process.env.AWS_ACCESS_KEY_ID = username || process.env.AWS_ACCESS_KEY_ID;
|
||||||
process.env.AWS_SECRET_ACCESS_KEY = password || process.env.AWS_SECRET_ACCESS_KEY;
|
process.env.AWS_SECRET_ACCESS_KEY = password || process.env.AWS_SECRET_ACCESS_KEY;
|
||||||
|
|
||||||
core.info(`⬇️ Retrieving docker login command through AWS CLI ${cliVersion} (${cliPath})...`);
|
core.info(`Retrieving docker login command through AWS CLI ${cliVersion} (${cliPath})...`);
|
||||||
const loginCmds = await aws.getDockerLoginCmds(cliVersion, registry, region, accountIDs);
|
const loginCmds = await aws.getDockerLoginCmds(cliVersion, registry, region, accountIDs);
|
||||||
|
|
||||||
core.info(`🔑 Logging into ${registry}...`);
|
core.info(`Logging into ${registry}...`);
|
||||||
loginCmds.forEach((loginCmd, index) => {
|
loginCmds.forEach((loginCmd, index) => {
|
||||||
execm.exec(loginCmd, [], true).then(res => {
|
execm.exec(loginCmd, [], true).then(res => {
|
||||||
if (res.stderr != '' && !res.success) {
|
if (res.stderr != '' && !res.success) {
|
||||||
throw new Error(res.stderr);
|
throw new Error(res.stderr);
|
||||||
}
|
}
|
||||||
if (loginCmds.length > 1) {
|
if (loginCmds.length > 1) {
|
||||||
core.info(`🎉 Login Succeeded! (${index}/${loginCmds.length})`);
|
core.info(`Login Succeeded! (${index}/${loginCmds.length})`);
|
||||||
} else {
|
} else {
|
||||||
core.info('🎉 Login Succeeded!');
|
core.info('Login Succeeded!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
import * as os from 'os';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {getInputs, Inputs} from './context';
|
import * as context from './context';
|
||||||
import * as docker from './docker';
|
import * as docker from './docker';
|
||||||
import * as stateHelper from './state-helper';
|
import * as stateHelper from './state-helper';
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
if (os.platform() !== 'linux') {
|
const {registry, username, password, logout} = context.getInputs();
|
||||||
throw new Error('Only supported on linux platform');
|
|
||||||
}
|
|
||||||
|
|
||||||
const {registry, username, password, logout} = getInputs();
|
|
||||||
stateHelper.setRegistry(registry);
|
stateHelper.setRegistry(registry);
|
||||||
stateHelper.setLogout(logout);
|
stateHelper.setLogout(logout);
|
||||||
await docker.login(registry, username, password);
|
await docker.login(registry, username, password);
|
||||||
|
|
Loading…
Reference in a new issue