diff --git a/.github/docker-login.png b/.github/docker-login.png index b6ef963..02594b9 100644 Binary files a/.github/docker-login.png and b/.github/docker-login.png differ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 815134b..ad86ddd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/README.md b/README.md index 25ef287..542e4bb 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 7c8782e..7700ae7 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -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'); diff --git a/dist/index.js b/dist/index.js index 24f6bdd..6a66bc3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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!'); } }); }); diff --git a/src/docker.ts b/src/docker.ts index 19aeb63..9924eb2 100644 --- a/src/docker.ts +++ b/src/docker.ts @@ -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!'); } }); }); diff --git a/src/main.ts b/src/main.ts index 06ff25c..f15082e 100644 --- a/src/main.ts +++ b/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 { 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);