Skip to content

Commit 28218f9

Browse files
authored
Merge pull request #66 from crazy-max/remove-os-limitation
Remove os limitation
2 parents 4b20628 + 7439f8b commit 28218f9

File tree

7 files changed

+40
-52
lines changed

7 files changed

+40
-52
lines changed

.github/docker-login.png

-730 Bytes
Loading

.github/workflows/ci.yml

+18
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ on:
1010
- 'releases/v*'
1111

1212
jobs:
13+
stop-docker:
14+
runs-on: ubuntu-latest
15+
steps:
16+
-
17+
name: Checkout
18+
uses: actions/checkout@v2
19+
-
20+
name: Stop docker
21+
run: |
22+
sudo systemctl stop docker
23+
-
24+
name: Login to GitHub Container Registry
25+
uses: ./
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.repository_owner }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
1331
dind:
1432
runs-on: ubuntu-latest
1533
env:

README.md

-10
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88

99
GitHub Action to login against a Docker registry.
1010

11-
> :bulb: See also:
12-
> * [setup-buildx](https://github.com/docker/setup-buildx-action) action
13-
> * [setup-qemu](https://github.com/docker/setup-qemu-action) action
14-
> * [build-push](https://github.com/docker/build-push-action) action
15-
1611
![Screenshot](.github/docker-login.png)
1712

1813
___
@@ -32,7 +27,6 @@ ___
3227
* [Customizing](#customizing)
3328
* [inputs](#inputs)
3429
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
35-
* [Limitation](#limitation)
3630

3731
## Usage
3832

@@ -433,7 +427,3 @@ updates:
433427
schedule:
434428
interval: "daily"
435429
```
436-
437-
## Limitation
438-
439-
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).

__tests__/main.test.ts

-11
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@ import * as stateHelper from '../src/state-helper';
66

77
import * as core from '@actions/core';
88

9-
test('errors when not run on linux platform', async () => {
10-
const platSpy = jest.spyOn(osm, 'platform');
11-
platSpy.mockImplementation(() => 'netbsd');
12-
13-
const coreSpy: jest.SpyInstance = jest.spyOn(core, 'setFailed');
14-
15-
await run();
16-
17-
expect(coreSpy).toHaveBeenCalledWith('Only supported on linux platform');
18-
});
19-
209
test('errors without username and password', async () => {
2110
const platSpy = jest.spyOn(osm, 'platform');
2211
platSpy.mockImplementation(() => 'linux');

dist/index.js

+11-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docker.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ export async function loginStandard(registry: string, username: string, password
2828
loginArgs.push(registry);
2929

3030
if (registry) {
31-
core.info(`🔑 Logging into ${registry}...`);
31+
core.info(`Logging into ${registry}...`);
3232
} else {
33-
core.info(`🔑 Logging into Docker Hub...`);
33+
core.info(`Logging into Docker Hub...`);
3434
}
3535
await execm.exec('docker', loginArgs, true, password).then(res => {
3636
if (res.stderr != '' && !res.success) {
3737
throw new Error(res.stderr);
3838
}
39-
core.info('🎉 Login Succeeded!');
39+
core.info(`Login Succeeded!`);
4040
});
4141
}
4242

@@ -47,27 +47,27 @@ export async function loginECR(registry: string, username: string, password: str
4747
const accountIDs = await aws.getAccountIDs(registry);
4848

4949
if (await aws.isPubECR(registry)) {
50-
core.info(`💡 AWS Public ECR detected with ${region} region`);
50+
core.info(`AWS Public ECR detected with ${region} region`);
5151
} else {
52-
core.info(`💡 AWS ECR detected with ${region} region`);
52+
core.info(`AWS ECR detected with ${region} region`);
5353
}
5454

5555
process.env.AWS_ACCESS_KEY_ID = username || process.env.AWS_ACCESS_KEY_ID;
5656
process.env.AWS_SECRET_ACCESS_KEY = password || process.env.AWS_SECRET_ACCESS_KEY;
5757

58-
core.info(`⬇️ Retrieving docker login command through AWS CLI ${cliVersion} (${cliPath})...`);
58+
core.info(`Retrieving docker login command through AWS CLI ${cliVersion} (${cliPath})...`);
5959
const loginCmds = await aws.getDockerLoginCmds(cliVersion, registry, region, accountIDs);
6060

61-
core.info(`🔑 Logging into ${registry}...`);
61+
core.info(`Logging into ${registry}...`);
6262
loginCmds.forEach((loginCmd, index) => {
6363
execm.exec(loginCmd, [], true).then(res => {
6464
if (res.stderr != '' && !res.success) {
6565
throw new Error(res.stderr);
6666
}
6767
if (loginCmds.length > 1) {
68-
core.info(`🎉 Login Succeeded! (${index}/${loginCmds.length})`);
68+
core.info(`Login Succeeded! (${index}/${loginCmds.length})`);
6969
} else {
70-
core.info('🎉 Login Succeeded!');
70+
core.info('Login Succeeded!');
7171
}
7272
});
7373
});

src/main.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import * as os from 'os';
21
import * as core from '@actions/core';
3-
import {getInputs, Inputs} from './context';
2+
import * as context from './context';
43
import * as docker from './docker';
54
import * as stateHelper from './state-helper';
65

76
export async function run(): Promise<void> {
87
try {
9-
if (os.platform() !== 'linux') {
10-
throw new Error('Only supported on linux platform');
11-
}
12-
13-
const {registry, username, password, logout} = getInputs();
8+
const {registry, username, password, logout} = context.getInputs();
149
stateHelper.setRegistry(registry);
1510
stateHelper.setLogout(logout);
1611
await docker.login(registry, username, password);

0 commit comments

Comments
 (0)