Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove os limitation #66

Merged
merged 1 commit into from Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified .github/docker-login.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions README.md
Expand Up @@ -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)

___
Expand All @@ -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

Expand Down Expand Up @@ -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).
11 changes: 0 additions & 11 deletions __tests__/main.test.ts
Expand Up @@ -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');
Expand Down
26 changes: 11 additions & 15 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/docker.ts
Expand Up @@ -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!`);
});
}

Expand All @@ -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!');
}
});
});
Expand Down
9 changes: 2 additions & 7 deletions src/main.ts
@@ -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);
Expand Down