Compare commits
1 Commits
1.4
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b60e4772d |
@@ -11,7 +11,6 @@
|
||||
"eslint-comments/no-use": "off",
|
||||
"import/no-namespace": "off",
|
||||
"no-unused-vars": "off",
|
||||
"i18n-text/no-en": "off",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
|
||||
"@typescript-eslint/no-require-imports": "error",
|
||||
|
||||
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
github: [KengoTODA]
|
||||
6
.github/auto-merge.yml
vendored
Normal file
6
.github/auto-merge.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
minApprovals:
|
||||
NONE: 0
|
||||
requiredLabels:
|
||||
- dependencies
|
||||
updateBranch: true
|
||||
mergeMethod: rebase
|
||||
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
commit-message:
|
||||
prefix: fix
|
||||
prefix-development: chore
|
||||
include: scope
|
||||
42
.github/workflows/test.yml
vendored
Normal file
42
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
name: 'build-test'
|
||||
on: # rebuild any PRs and main branch changes
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'releases/*'
|
||||
|
||||
jobs:
|
||||
build: # make sure build/ci work properly
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
# Make sure the release step uses its own credentials.
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
cache: npm
|
||||
node-version-file: '.nvmrc'
|
||||
- run: |
|
||||
npm ci
|
||||
npm run all
|
||||
- name: Run semantic-release
|
||||
run: |
|
||||
npx semantic-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PAT_TO_PUSH }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
test: # make sure the action works on a clean machine without building
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./
|
||||
with:
|
||||
version: '1.26.2'
|
||||
- uses: ./
|
||||
with:
|
||||
version: '2.4.1'
|
||||
- uses: ./
|
||||
with:
|
||||
version: 'v2.4.1'
|
||||
2
LICENSE
2
LICENSE
@@ -1,7 +1,7 @@
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2021-2024 Kengo TODA
|
||||
Copyright (c) 2021 Kengo TODA
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
20
README.md
20
README.md
@@ -4,29 +4,15 @@
|
||||
|
||||
This action downloads the `docker-compose` command and add it to the `PATH` for following executions. It supports the Linux environment only.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The `docker-compose` command is now deprecated, consider to use the `docker compose` sub command instead. Refer to [Docker official blog](https://www.docker.com/blog/announcing-compose-v2-general-availability/) for detail.
|
||||
|
||||
## How to use
|
||||
|
||||
Add a step to your workflow like below:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: KengoTODA/actions-setup-docker-compose@v1
|
||||
with:
|
||||
version: '2.14.2' # the full version of `docker-compose` command
|
||||
```
|
||||
|
||||
Or set a `GITHUB_TOKEN` environment variable, to use the latest released version:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: KengoTODA/actions-setup-docker-compose@main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
version: '1.29.2'
|
||||
```
|
||||
|
||||
The 'latest release' here means [the most recent non-prerelease, non-draft release, sorted by the created_at attribute](https://octokit.github.io/rest.js/v19#repos-get-latest-release).
|
||||
|
||||
Note that the `GITHUB_TOKEN` should have [`contents: read` permission](https://docs.github.com/en/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#contents) to fetch data from the GitHub.com.
|
||||
The `version` parameter is required, specify the full version of `docker-compose` command.
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
import {install, runCommand} from '../src/install'
|
||||
import * as core from '@actions/core'
|
||||
|
||||
import {describe, expect, it, test} from '@jest/globals'
|
||||
import {expect, test} from '@jest/globals'
|
||||
|
||||
describe('runCommand', () => {
|
||||
it('runs a command and returns its stdout', async () => {
|
||||
const result = await runCommand('echo foo bar')
|
||||
expect(result).toBe('foo bar')
|
||||
})
|
||||
test('runCommand', async () => {
|
||||
const result = await runCommand('echo foo bar')
|
||||
expect(result).toBe('foo bar')
|
||||
})
|
||||
|
||||
describe('install', () => {
|
||||
const cases = ['1.29.1', '1.29.2', '2.2.3', 'v2.2.3', 'v2.10.2']
|
||||
test.each(cases)('can install version %p', async (version: string) => {
|
||||
const commandPath = await install(version)
|
||||
core.addPath(commandPath)
|
||||
const result = await runCommand('docker-compose version')
|
||||
expect(result).toContain(version)
|
||||
})
|
||||
it('can install latest version', async () => {
|
||||
const commandPath = await install('latest')
|
||||
core.addPath(commandPath)
|
||||
const result = await runCommand('docker-compose version')
|
||||
expect(result).not.toBeFalsy()
|
||||
})
|
||||
async function testVersion(version: string) {
|
||||
const commandPath = await install(version)
|
||||
core.addPath(commandPath)
|
||||
const result = await runCommand('docker-compose version')
|
||||
expect(result).toContain(version)
|
||||
}
|
||||
|
||||
test('Install the right version', async () => {
|
||||
await testVersion('1.29.1')
|
||||
await testVersion('1.29.2')
|
||||
await testVersion('2.2.3')
|
||||
await testVersion('v2.2.3')
|
||||
})
|
||||
|
||||
13
action.yml
Normal file
13
action.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
name: 'Setup docker-compose'
|
||||
description: 'Automate download and set up process for docker-compose command'
|
||||
author: 'Kengo TODA <skypencil@gmail.com>'
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
description: 'the version of docker-compose command'
|
||||
branding:
|
||||
color: blue
|
||||
icon: play
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
31581
dist/index.js
vendored
31581
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
18898
package-lock.json
generated
18898
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
54
package.json
54
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kengotoda/actions-setup-docker-compose",
|
||||
"version": "1.2.2",
|
||||
"version": "1.0.7",
|
||||
"description": "the GitHub Action setting up docker-compose command",
|
||||
"main": "lib/main.js",
|
||||
"private": false,
|
||||
@@ -28,25 +28,49 @@
|
||||
"author": "Kengo TODA <skypencil@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@octokit/action": "^6.0.7"
|
||||
"@actions/core": "^1.4.0",
|
||||
"@actions/exec": "^1.1.0",
|
||||
"@actions/tool-cache": "^1.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/exec": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@types/node": "^20.0.0",
|
||||
"@typescript-eslint/parser": "^7.0.0",
|
||||
"@vercel/ncc": "^0.38.0",
|
||||
"@types/node": "^17.0.0",
|
||||
"@typescript-eslint/parser": "^5.3.0",
|
||||
"@vercel/ncc": "^0.33.0",
|
||||
"eslint": "^8.1.0",
|
||||
"eslint-plugin-github": "^4.10.2",
|
||||
"eslint-plugin-jest": "^28.0.0",
|
||||
"jest": "^29.0.0",
|
||||
"eslint-plugin-github": "^4.3.3",
|
||||
"eslint-plugin-jest": "^26.0.0",
|
||||
"jest": "^27.0.6",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "3.3.3",
|
||||
"semantic-release": "^24.0.0",
|
||||
"ts-jest": "^29.0.0",
|
||||
"typescript": "^5.0.0"
|
||||
"prettier": "2.6.2",
|
||||
"semantic-release": "^19.0.2",
|
||||
"ts-jest": "^27.0.3",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"release": {
|
||||
"branches": "main",
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/github",
|
||||
[
|
||||
"@semantic-release/exec",
|
||||
{
|
||||
"prepare": "npm run package"
|
||||
}
|
||||
],
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": [
|
||||
"dist",
|
||||
"package.json"
|
||||
],
|
||||
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"packageRules": [
|
||||
{
|
||||
"matchDepTypes": ["devDependencies"],
|
||||
"matchUpdateTypes": ["minor", "patch"],
|
||||
"matchCurrentVersion": "!/^0/",
|
||||
"automerge": true
|
||||
}
|
||||
],
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import {cacheFile, downloadTool} from '@actions/tool-cache'
|
||||
import {exec} from '@actions/exec'
|
||||
import * as core from '@actions/core'
|
||||
import {Octokit} from '@octokit/action'
|
||||
|
||||
export async function runCommand(command: string): Promise<string> {
|
||||
let output = ''
|
||||
@@ -24,8 +22,7 @@ async function installOnLinux(version: string): Promise<string> {
|
||||
if (!version.startsWith('v') && parseInt(version.split('.')[0], 10) >= 2) {
|
||||
version = `v${version}`
|
||||
}
|
||||
const url = `https://gh.api.99988866.xyz/https://github.com/docker/compose/releases/download/${version}/docker-compose-${await system}-${await hardware}`
|
||||
runCommand(`echo ${url}`)
|
||||
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${await system}-${await hardware}`
|
||||
const installerPath = await downloadTool(url)
|
||||
await exec(`chmod +x ${installerPath}`)
|
||||
const cachedPath = await cacheFile(
|
||||
@@ -37,20 +34,7 @@ async function installOnLinux(version: string): Promise<string> {
|
||||
return cachedPath
|
||||
}
|
||||
|
||||
async function findLatestVersion(): Promise<string> {
|
||||
const octokit = new Octokit()
|
||||
const response = await octokit.repos.getLatestRelease({
|
||||
owner: 'docker',
|
||||
repo: 'compose'
|
||||
})
|
||||
return response.data.tag_name
|
||||
}
|
||||
|
||||
export async function install(version: string): Promise<string> {
|
||||
if (version === 'latest') {
|
||||
version = await findLatestVersion()
|
||||
core.info(`Requested to use the latest version: ${version}`)
|
||||
}
|
||||
switch (process.platform) {
|
||||
case 'linux':
|
||||
return installOnLinux(version)
|
||||
|
||||
@@ -4,7 +4,7 @@ import {install} from './install'
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const version: string = core.getInput('version', {
|
||||
trimWhitespace: true
|
||||
required: true
|
||||
})
|
||||
const commandPath = await install(version)
|
||||
core.addPath(commandPath)
|
||||
|
||||
Reference in New Issue
Block a user