Merge pull request #66 from crazy-max/remove-os-limitation

Remove os limitation
This commit is contained in:
CrazyMax 2021-04-28 00:38:38 +02:00 committed by GitHub
commit 28218f9b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 52 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

@ -10,6 +10,24 @@ on:
- 'releases/v*'
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:
runs-on: ubuntu-latest
env:

@ -8,11 +8,6 @@
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)
___
@ -32,7 +27,6 @@ ___
* [Customizing](#customizing)
* [inputs](#inputs)
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
* [Limitation](#limitation)
## Usage
@ -433,7 +427,3 @@ updates:
schedule:
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';
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 () => {
const platSpy = jest.spyOn(osm, 'platform');
platSpy.mockImplementation(() => 'linux');

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 });
exports.run = void 0;
const os = __importStar(__webpack_require__(87));
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 stateHelper = __importStar(__webpack_require__(647));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
if (os.platform() !== 'linux') {
throw new Error('Only supported on linux platform');
}
const { registry, username, password, logout } = context_1.getInputs();
const { registry, username, password, logout } = context.getInputs();
stateHelper.setRegistry(registry);
stateHelper.setLogout(logout);
yield docker.login(registry, username, password);
@ -3069,16 +3065,16 @@ function loginStandard(registry, username, password) {
loginArgs.push('--username', username);
loginArgs.push(registry);
if (registry) {
core.info(`🔑 Logging into ${registry}...`);
core.info(`Logging into ${registry}...`);
}
else {
core.info(`🔑 Logging into Docker Hub...`);
core.info(`Logging into Docker Hub...`);
}
yield execm.exec('docker', loginArgs, true, password).then(res => {
if (res.stderr != '' && !res.success) {
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 accountIDs = yield aws.getAccountIDs(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 {
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_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);
core.info(`🔑 Logging into ${registry}...`);
core.info(`Logging into ${registry}...`);
loginCmds.forEach((loginCmd, index) => {
execm.exec(loginCmd, [], true).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
}
if (loginCmds.length > 1) {
core.info(`🎉 Login Succeeded! (${index}/${loginCmds.length})`);
core.info(`Login Succeeded! (${index}/${loginCmds.length})`);
}
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);
if (registry) {
core.info(`🔑 Logging into ${registry}...`);
core.info(`Logging into ${registry}...`);
} else {
core.info(`🔑 Logging into Docker Hub...`);
core.info(`Logging into Docker Hub...`);
}
await execm.exec('docker', loginArgs, true, password).then(res => {
if (res.stderr != '' && !res.success) {
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);
if (await aws.isPubECR(registry)) {
core.info(`💡 AWS Public ECR detected with ${region} region`);
core.info(`AWS Public ECR detected with ${region} region`);
} 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_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);
core.info(`🔑 Logging into ${registry}...`);
core.info(`Logging into ${registry}...`);
loginCmds.forEach((loginCmd, index) => {
execm.exec(loginCmd, [], true).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
}
if (loginCmds.length > 1) {
core.info(`🎉 Login Succeeded! (${index}/${loginCmds.length})`);
core.info(`Login Succeeded! (${index}/${loginCmds.length})`);
} 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 {getInputs, Inputs} from './context';
import * as context from './context';
import * as docker from './docker';
import * as stateHelper from './state-helper';
export async function run(): Promise<void> {
try {
if (os.platform() !== 'linux') {
throw new Error('Only supported on linux platform');
}
const {registry, username, password, logout} = getInputs();
const {registry, username, password, logout} = context.getInputs();
stateHelper.setRegistry(registry);
stateHelper.setLogout(logout);
await docker.login(registry, username, password);