Compare commits
	
		
			15 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					0d135e0c2f | ||
| 
						 | 
					36d8e005ca | ||
| 
						 | 
					012185ccbe | ||
| 
						 | 
					881cacd606 | ||
| 
						 | 
					076026291d | ||
| 
						 | 
					f4b1b8d38d | ||
| 
						 | 
					316c3e4a7c | ||
| 
						 | 
					5b1c96aee8 | ||
| 
						 | 
					0f034385ce | ||
| 
						 | 
					72750233ac | ||
| 
						 | 
					abdb186058 | ||
| 
						 | 
					9b365965c1 | ||
| 
						 | 
					583a3147f8 | ||
| 
						 | 
					2913c18445 | ||
| 
						 | 
					26e1d017b6 | 
							
								
								
									
										
											BIN
										
									
								
								.github/buildkit-container-logs.png
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.github/buildkit-container-logs.png
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 13 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								.github/setup-buildx-action.png
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								.github/setup-buildx-action.png
									
									
									
									
										vendored
									
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 11 KiB  | 
							
								
								
									
										132
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										132
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							@@ -35,11 +35,13 @@ jobs:
 | 
			
		||||
        with:
 | 
			
		||||
          version: ${{ matrix.buildx-version }}
 | 
			
		||||
      -
 | 
			
		||||
        name: Builder instance name
 | 
			
		||||
        run: echo ${{ steps.buildx.outputs.name }}
 | 
			
		||||
      -
 | 
			
		||||
        name: Available platforms
 | 
			
		||||
        run: echo ${{ steps.buildx.outputs.platforms }}
 | 
			
		||||
        name: Inspect builder
 | 
			
		||||
        run: |
 | 
			
		||||
          echo "Name:      ${{ steps.buildx.outputs.name }}"
 | 
			
		||||
          echo "Endpoint:  ${{ steps.buildx.outputs.endpoint }}"
 | 
			
		||||
          echo "Status:    ${{ steps.buildx.outputs.status }}"
 | 
			
		||||
          echo "Flags:     ${{ steps.buildx.outputs.flags }}"
 | 
			
		||||
          echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
 | 
			
		||||
      -
 | 
			
		||||
        name: Dump context
 | 
			
		||||
        uses: crazy-max/ghaction-dump-context@v1
 | 
			
		||||
@@ -55,15 +57,81 @@ jobs:
 | 
			
		||||
        id: buildx1
 | 
			
		||||
        uses: ./
 | 
			
		||||
      -
 | 
			
		||||
        name: Builder 1 instance name
 | 
			
		||||
        run: echo ${{ steps.buildx1.outputs.name }}
 | 
			
		||||
        name: Inspect builder 1
 | 
			
		||||
        run: |
 | 
			
		||||
          echo "Name:      ${{ steps.buildx1.outputs.name }}"
 | 
			
		||||
          echo "Endpoint:  ${{ steps.buildx1.outputs.endpoint }}"
 | 
			
		||||
          echo "Status:    ${{ steps.buildx1.outputs.status }}"
 | 
			
		||||
          echo "Flags:     ${{ steps.buildx1.outputs.flags }}"
 | 
			
		||||
          echo "Platforms: ${{ steps.buildx1.outputs.platforms }}"
 | 
			
		||||
      -
 | 
			
		||||
        name: Set up Docker Buildx 2
 | 
			
		||||
        id: buildx2
 | 
			
		||||
        uses: ./
 | 
			
		||||
      -
 | 
			
		||||
        name: Builder 2 instance name
 | 
			
		||||
        run: echo ${{ steps.buildx2.outputs.name }}
 | 
			
		||||
        name: Inspect builder 2
 | 
			
		||||
        run: |
 | 
			
		||||
          echo "Name:      ${{ steps.buildx2.outputs.name }}"
 | 
			
		||||
          echo "Endpoint:  ${{ steps.buildx2.outputs.endpoint }}"
 | 
			
		||||
          echo "Status:    ${{ steps.buildx2.outputs.status }}"
 | 
			
		||||
          echo "Flags:     ${{ steps.buildx2.outputs.flags }}"
 | 
			
		||||
          echo "Platforms: ${{ steps.buildx2.outputs.platforms }}"
 | 
			
		||||
 | 
			
		||||
  error:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      -
 | 
			
		||||
        name: Checkout
 | 
			
		||||
        uses: actions/checkout@v2
 | 
			
		||||
      -
 | 
			
		||||
        name: Stop docker
 | 
			
		||||
        run: |
 | 
			
		||||
          sudo systemctl stop docker
 | 
			
		||||
      -
 | 
			
		||||
        name: Set up Docker Buildx
 | 
			
		||||
        id: buildx
 | 
			
		||||
        continue-on-error: true
 | 
			
		||||
        uses: ./
 | 
			
		||||
      -
 | 
			
		||||
        name: Check
 | 
			
		||||
        run: |
 | 
			
		||||
          echo "${{ toJson(steps.buildx) }}"
 | 
			
		||||
          if [ "${{ steps.buildx.outcome }}" != "failure" ] || [ "${{ steps.buildx.conclusion }}" != "success" ]; then
 | 
			
		||||
            echo "::error::Should have failed"
 | 
			
		||||
            exit 1
 | 
			
		||||
          fi
 | 
			
		||||
      -
 | 
			
		||||
        name: Dump context
 | 
			
		||||
        if: always()
 | 
			
		||||
        uses: crazy-max/ghaction-dump-context@v1
 | 
			
		||||
 | 
			
		||||
  debug:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      -
 | 
			
		||||
        name: Checkout
 | 
			
		||||
        uses: actions/checkout@v2
 | 
			
		||||
      -
 | 
			
		||||
        name: Create Dockerfile
 | 
			
		||||
        run: |
 | 
			
		||||
          cat > ./Dockerfile <<EOL
 | 
			
		||||
          FROM alpine
 | 
			
		||||
          RUN uname -a
 | 
			
		||||
          EOL
 | 
			
		||||
      -
 | 
			
		||||
        name: Set up QEMU
 | 
			
		||||
        uses: docker/setup-qemu-action@v1
 | 
			
		||||
      -
 | 
			
		||||
        name: Set up Docker Buildx
 | 
			
		||||
        uses: ./
 | 
			
		||||
        with:
 | 
			
		||||
          buildkitd-flags: --debug
 | 
			
		||||
      -
 | 
			
		||||
        name: Build
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        with:
 | 
			
		||||
          context: .
 | 
			
		||||
          platforms: linux/amd64,linux/arm64,linux/ppc64le
 | 
			
		||||
 | 
			
		||||
  install:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
@@ -175,6 +243,40 @@ jobs:
 | 
			
		||||
        uses: ./
 | 
			
		||||
        with:
 | 
			
		||||
          endpoint: mycontext
 | 
			
		||||
        env:
 | 
			
		||||
          DOCKER_CONTEXT: mycontext
 | 
			
		||||
 | 
			
		||||
  config:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
      -
 | 
			
		||||
        name: Checkout
 | 
			
		||||
        uses: actions/checkout@v2
 | 
			
		||||
      -
 | 
			
		||||
        name: Create buildkitd conf
 | 
			
		||||
        run: |
 | 
			
		||||
          cat > /tmp/buildkitd.toml <<EOL
 | 
			
		||||
          debug = true
 | 
			
		||||
          [registry."docker.io"]
 | 
			
		||||
            mirrors = ["mirror.gcr.io"]
 | 
			
		||||
          EOL
 | 
			
		||||
      -
 | 
			
		||||
        name: Create Dockerfile
 | 
			
		||||
        run: |
 | 
			
		||||
          cat > ./Dockerfile <<EOL
 | 
			
		||||
          FROM alpine
 | 
			
		||||
          EOL
 | 
			
		||||
      -
 | 
			
		||||
        name: Set up Docker Buildx
 | 
			
		||||
        uses: ./
 | 
			
		||||
        with:
 | 
			
		||||
          buildkitd-flags: --debug
 | 
			
		||||
          config: /tmp/buildkitd.toml
 | 
			
		||||
      -
 | 
			
		||||
        name: Build
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        with:
 | 
			
		||||
          context: .
 | 
			
		||||
 | 
			
		||||
  with-qemu:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
@@ -204,8 +306,10 @@ jobs:
 | 
			
		||||
        with:
 | 
			
		||||
          version: ${{ matrix.buildx-version }}
 | 
			
		||||
      -
 | 
			
		||||
        name: Available platforms
 | 
			
		||||
        run: echo ${{ steps.buildx.outputs.platforms }}
 | 
			
		||||
      -
 | 
			
		||||
        name: Builder instance name
 | 
			
		||||
        run: echo ${{ steps.buildx.outputs.name }}
 | 
			
		||||
        name: Inspect builder
 | 
			
		||||
        run: |
 | 
			
		||||
          echo "Name:      ${{ steps.buildx.outputs.name }}"
 | 
			
		||||
          echo "Endpoint:  ${{ steps.buildx.outputs.endpoint }}"
 | 
			
		||||
          echo "Status:    ${{ steps.buildx.outputs.status }}"
 | 
			
		||||
          echo "Flags:     ${{ steps.buildx.outputs.flags }}"
 | 
			
		||||
          echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							@@ -22,6 +22,9 @@ jobs:
 | 
			
		||||
        uses: docker/bake-action@v1
 | 
			
		||||
        with:
 | 
			
		||||
          targets: validate
 | 
			
		||||
      -
 | 
			
		||||
        name: Set up Docker Buildx
 | 
			
		||||
        uses: ./
 | 
			
		||||
      -
 | 
			
		||||
        name: Test
 | 
			
		||||
        uses: docker/bake-action@v1
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										47
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								README.md
									
									
									
									
									
								
							@@ -25,8 +25,9 @@ ___
 | 
			
		||||
  * [inputs](#inputs)
 | 
			
		||||
  * [outputs](#outputs)
 | 
			
		||||
  * [environment variables](#environment-variables)
 | 
			
		||||
* [Notes](#notes)
 | 
			
		||||
  * [BuildKit container logs](#buildkit-container-logs)
 | 
			
		||||
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
 | 
			
		||||
* [Limitation](#limitation)
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
 | 
			
		||||
@@ -50,11 +51,13 @@ jobs:
 | 
			
		||||
        id: buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
      -
 | 
			
		||||
        name: Builder instance name
 | 
			
		||||
        run: echo ${{ steps.buildx.outputs.name }}
 | 
			
		||||
      -
 | 
			
		||||
        name: Available platforms
 | 
			
		||||
        run: echo ${{ steps.buildx.outputs.platforms }}
 | 
			
		||||
        name: Inspect builder
 | 
			
		||||
        run: |
 | 
			
		||||
          echo "Name:      ${{ steps.buildx.outputs.name }}"
 | 
			
		||||
          echo "Endpoint:  ${{ steps.buildx.outputs.endpoint }}"
 | 
			
		||||
          echo "Status:    ${{ steps.buildx.outputs.status }}"
 | 
			
		||||
          echo "Flags:     ${{ steps.buildx.outputs.flags }}"
 | 
			
		||||
          echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### With QEMU
 | 
			
		||||
@@ -129,6 +132,7 @@ Following inputs can be used as `step.with` keys
 | 
			
		||||
| `install`          | Bool    | Sets up `docker build` command as an alias to `docker buildx` (default `false`) |
 | 
			
		||||
| `use`              | Bool    | Switch to this builder instance (default `true`) |
 | 
			
		||||
| `endpoint`         | String  | [Optional address for docker socket](https://github.com/docker/buildx/blob/master/docs/reference/buildx_create.md#description) or context from `docker context ls` |
 | 
			
		||||
| `config`           | String  | [BuildKit config file](https://github.com/docker/buildx/blob/master/docs/reference/buildx_create.md#config) |
 | 
			
		||||
 | 
			
		||||
> `CSV` type must be a newline-delimited string
 | 
			
		||||
> ```yaml
 | 
			
		||||
@@ -146,8 +150,12 @@ Following outputs are available
 | 
			
		||||
 | 
			
		||||
| Name          | Type    | Description                           |
 | 
			
		||||
|---------------|---------|---------------------------------------|
 | 
			
		||||
| `name`        | String  | Builder instance name |
 | 
			
		||||
| `platforms`   | String  | Available platforms (comma separated) |
 | 
			
		||||
| `name`        | String  | Builder name |
 | 
			
		||||
| `driver`      | String  | Builder driver |
 | 
			
		||||
| `endpoint`    | String  | Builder node endpoint |
 | 
			
		||||
| `status`      | String  | Builder node status |
 | 
			
		||||
| `flags`       | String  | Builder node flags (if applicable) |
 | 
			
		||||
| `platforms`   | String  | Builder node platforms available (comma separated) |
 | 
			
		||||
 | 
			
		||||
### environment variables
 | 
			
		||||
 | 
			
		||||
@@ -157,6 +165,25 @@ The following [official docker environment variables](https://docs.docker.com/en
 | 
			
		||||
|-----------------|---------|-------------|-------------------------------------------------|
 | 
			
		||||
| `DOCKER_CONFIG` | String  | `~/.docker` | The location of your client configuration files |
 | 
			
		||||
 | 
			
		||||
## Notes
 | 
			
		||||
 | 
			
		||||
### BuildKit container logs
 | 
			
		||||
 | 
			
		||||
To display BuildKit container logs (when `docker-container` driver is used) you have to [enable step debug logging](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging#enabling-step-debug-logging)
 | 
			
		||||
or you can also enable debugging in the [setup-buildx action step](https://github.com/docker/setup-buildx-action):
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
  -
 | 
			
		||||
    name: Set up Docker Buildx
 | 
			
		||||
    uses: docker/setup-buildx-action@v1
 | 
			
		||||
    with:
 | 
			
		||||
      buildkitd-flags: --debug
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Logs will be available at the end of a job:
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
## Keep up-to-date with GitHub Dependabot
 | 
			
		||||
 | 
			
		||||
Since [Dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot)
 | 
			
		||||
@@ -172,7 +199,3 @@ updates:
 | 
			
		||||
    schedule:
 | 
			
		||||
      interval: "daily"
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Limitation
 | 
			
		||||
 | 
			
		||||
This action is only available for Linux [virtual environments](https://docs.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#supported-virtual-environments-and-hardware-resources).
 | 
			
		||||
 
 | 
			
		||||
@@ -25,17 +25,19 @@ describe('parseVersion', () => {
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
describe('platforms', () => {
 | 
			
		||||
describe('inspect', () => {
 | 
			
		||||
  async function isDaemonRunning() {
 | 
			
		||||
    return await docker.isDaemonRunning();
 | 
			
		||||
  }
 | 
			
		||||
  (isDaemonRunning() ? it : it.skip)(
 | 
			
		||||
    'valid',
 | 
			
		||||
    async () => {
 | 
			
		||||
      const platforms = buildx.platforms();
 | 
			
		||||
      console.log(`platforms: ${platforms}`);
 | 
			
		||||
      expect(platforms).not.toBeUndefined();
 | 
			
		||||
      expect(platforms).not.toEqual('');
 | 
			
		||||
      const builder = await buildx.inspect('');
 | 
			
		||||
      console.log('builder', builder);
 | 
			
		||||
      expect(builder).not.toBeUndefined();
 | 
			
		||||
      expect(builder.name).not.toEqual('');
 | 
			
		||||
      expect(builder.driver).not.toEqual('');
 | 
			
		||||
      expect(builder.node_platforms).not.toEqual('');
 | 
			
		||||
    },
 | 
			
		||||
    100000
 | 
			
		||||
  );
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import * as os from 'os';
 | 
			
		||||
import * as context from '../src/context';
 | 
			
		||||
 | 
			
		||||
describe('getInputList', () => {
 | 
			
		||||
@@ -78,6 +79,27 @@ describe('asyncForEach', () => {
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
describe('setOutput', () => {
 | 
			
		||||
  beforeEach(() => {
 | 
			
		||||
    process.stdout.write = jest.fn();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('setOutput produces the correct command', () => {
 | 
			
		||||
    context.setOutput('some output', 'some value');
 | 
			
		||||
    assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('setOutput handles bools', () => {
 | 
			
		||||
    context.setOutput('some output', false);
 | 
			
		||||
    assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('setOutput handles numbers', () => {
 | 
			
		||||
    context.setOutput('some output', 1.01);
 | 
			
		||||
    assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
 | 
			
		||||
function getInputName(name: string): string {
 | 
			
		||||
  return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
 | 
			
		||||
@@ -86,3 +108,11 @@ function getInputName(name: string): string {
 | 
			
		||||
function setInput(name: string, value: string): void {
 | 
			
		||||
  process.env[getInputName(name)] = value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Assert that process.stdout.write calls called only with the given arguments.
 | 
			
		||||
function assertWriteCalls(calls: string[]): void {
 | 
			
		||||
  expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
 | 
			
		||||
  for (let i = 0; i < calls.length; i++) {
 | 
			
		||||
    expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								action.yml
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								action.yml
									
									
									
									
									
								
							@@ -32,12 +32,23 @@ inputs:
 | 
			
		||||
  endpoint:
 | 
			
		||||
    description: 'Optional address for docker socket or context from `docker context ls`'
 | 
			
		||||
    required: false
 | 
			
		||||
  config:
 | 
			
		||||
    description: 'BuildKit config file'
 | 
			
		||||
    required: false
 | 
			
		||||
 | 
			
		||||
outputs:
 | 
			
		||||
  name:
 | 
			
		||||
    description: 'Builder instance name'
 | 
			
		||||
    description: 'Builder name'
 | 
			
		||||
  driver:
 | 
			
		||||
    description: 'Builder driver'
 | 
			
		||||
  endpoint:
 | 
			
		||||
    description: 'Builder node endpoint'
 | 
			
		||||
  status:
 | 
			
		||||
    description: 'Builder node status'
 | 
			
		||||
  flags:
 | 
			
		||||
    description: 'Builder node flags (if applicable)'
 | 
			
		||||
  platforms:
 | 
			
		||||
    description: 'Available platforms (comma separated)'
 | 
			
		||||
    description: 'Builder node platforms available (comma separated)'
 | 
			
		||||
 | 
			
		||||
runs:
 | 
			
		||||
  using: 'node12'
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										160
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										160
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -519,12 +519,13 @@ const context = __importStar(__webpack_require__(842));
 | 
			
		||||
const mexec = __importStar(__webpack_require__(757));
 | 
			
		||||
const stateHelper = __importStar(__webpack_require__(647));
 | 
			
		||||
function run() {
 | 
			
		||||
    var _a;
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            if (os.platform() !== 'linux') {
 | 
			
		||||
                core.setFailed('Only supported on linux platform');
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            core.startGroup(`Docker info`);
 | 
			
		||||
            yield exec.exec('docker', ['version']);
 | 
			
		||||
            yield exec.exec('docker', ['info']);
 | 
			
		||||
            core.endGroup();
 | 
			
		||||
            const inputs = yield context.getInputs();
 | 
			
		||||
            const dockerConfigHome = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
 | 
			
		||||
            if (!(yield buildx.isAvailable()) || inputs.version) {
 | 
			
		||||
@@ -535,7 +536,7 @@ function run() {
 | 
			
		||||
            const buildxVersion = yield buildx.getVersion();
 | 
			
		||||
            core.info(`Using buildx ${buildxVersion}`);
 | 
			
		||||
            const builderName = inputs.driver == 'docker' ? 'default' : `builder-${__webpack_require__(840).v4()}`;
 | 
			
		||||
            core.setOutput('name', builderName);
 | 
			
		||||
            context.setOutput('name', builderName);
 | 
			
		||||
            stateHelper.setBuilderName(builderName);
 | 
			
		||||
            if (inputs.driver !== 'docker') {
 | 
			
		||||
                core.startGroup(`Creating a new builder instance`);
 | 
			
		||||
@@ -554,6 +555,9 @@ function run() {
 | 
			
		||||
                if (inputs.endpoint) {
 | 
			
		||||
                    createArgs.push(inputs.endpoint);
 | 
			
		||||
                }
 | 
			
		||||
                if (inputs.config) {
 | 
			
		||||
                    createArgs.push('--config', inputs.config);
 | 
			
		||||
                }
 | 
			
		||||
                yield exec.exec('docker', createArgs);
 | 
			
		||||
                core.endGroup();
 | 
			
		||||
                core.startGroup(`Booting builder`);
 | 
			
		||||
@@ -569,11 +573,24 @@ function run() {
 | 
			
		||||
                yield exec.exec('docker', ['buildx', 'install']);
 | 
			
		||||
                core.endGroup();
 | 
			
		||||
            }
 | 
			
		||||
            core.startGroup(`Extracting available platforms`);
 | 
			
		||||
            const platforms = yield buildx.platforms();
 | 
			
		||||
            core.info(`${platforms}`);
 | 
			
		||||
            core.setOutput('platforms', platforms);
 | 
			
		||||
            core.startGroup(`Inspect builder`);
 | 
			
		||||
            const builder = yield buildx.inspect(builderName);
 | 
			
		||||
            core.info(JSON.stringify(builder, undefined, 2));
 | 
			
		||||
            context.setOutput('driver', builder.driver);
 | 
			
		||||
            context.setOutput('endpoint', builder.node_endpoint);
 | 
			
		||||
            context.setOutput('status', builder.node_status);
 | 
			
		||||
            context.setOutput('flags', builder.node_flags);
 | 
			
		||||
            context.setOutput('platforms', builder.node_platforms);
 | 
			
		||||
            core.endGroup();
 | 
			
		||||
            if (inputs.driver == 'docker-container') {
 | 
			
		||||
                stateHelper.setContainerName(`buildx_buildkit_${builder.node_name}`);
 | 
			
		||||
                core.startGroup(`BuildKit version`);
 | 
			
		||||
                core.info(yield buildx.getBuildKitVersion(`buildx_buildkit_${builder.node_name}`));
 | 
			
		||||
                core.endGroup();
 | 
			
		||||
            }
 | 
			
		||||
            if (core.isDebug() || ((_a = builder.node_flags) === null || _a === void 0 ? void 0 : _a.includes('--debug'))) {
 | 
			
		||||
                stateHelper.setDebug('true');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (error) {
 | 
			
		||||
            core.setFailed(error.message);
 | 
			
		||||
@@ -582,14 +599,24 @@ function run() {
 | 
			
		||||
}
 | 
			
		||||
function cleanup() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        if (stateHelper.builderName.length == 0) {
 | 
			
		||||
            return;
 | 
			
		||||
        if (stateHelper.IsDebug && stateHelper.containerName.length > 0) {
 | 
			
		||||
            core.startGroup(`BuildKit container logs`);
 | 
			
		||||
            yield mexec.exec('docker', ['logs', `${stateHelper.containerName}`], false).then(res => {
 | 
			
		||||
                if (res.stderr.length > 0 && !res.success) {
 | 
			
		||||
                    core.warning(res.stderr);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            core.endGroup();
 | 
			
		||||
        }
 | 
			
		||||
        if (stateHelper.builderName.length > 0) {
 | 
			
		||||
            core.startGroup(`Removing builder`);
 | 
			
		||||
            yield mexec.exec('docker', ['buildx', 'rm', `${stateHelper.builderName}`], false).then(res => {
 | 
			
		||||
                if (res.stderr.length > 0 && !res.success) {
 | 
			
		||||
                    core.warning(res.stderr);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            core.endGroup();
 | 
			
		||||
        }
 | 
			
		||||
        yield mexec.exec('docker', ['buildx', 'rm', `${stateHelper.builderName}`], false).then(res => {
 | 
			
		||||
            if (res.stderr != '' && !res.success) {
 | 
			
		||||
                core.warning(res.stderr);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
if (!stateHelper.IsPost) {
 | 
			
		||||
@@ -1484,6 +1511,7 @@ exports.getInput = getInput;
 | 
			
		||||
 */
 | 
			
		||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
 | 
			
		||||
function setOutput(name, value) {
 | 
			
		||||
    process.stdout.write(os.EOL);
 | 
			
		||||
    command_1.issueCommand('set-output', { name }, value);
 | 
			
		||||
}
 | 
			
		||||
exports.setOutput = setOutput;
 | 
			
		||||
@@ -2122,7 +2150,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.install = exports.platforms = exports.isAvailable = exports.parseVersion = exports.getVersion = void 0;
 | 
			
		||||
exports.getBuildKitVersion = exports.install = exports.inspect = exports.isAvailable = exports.parseVersion = exports.getVersion = void 0;
 | 
			
		||||
const fs = __importStar(__webpack_require__(747));
 | 
			
		||||
const path = __importStar(__webpack_require__(622));
 | 
			
		||||
const semver = __importStar(__webpack_require__(383));
 | 
			
		||||
@@ -2135,7 +2163,7 @@ const tc = __importStar(__webpack_require__(784));
 | 
			
		||||
function getVersion() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        return yield exec.exec(`docker`, ['buildx', 'version'], true).then(res => {
 | 
			
		||||
            if (res.stderr != '' && !res.success) {
 | 
			
		||||
            if (res.stderr.length > 0 && !res.success) {
 | 
			
		||||
                throw new Error(res.stderr);
 | 
			
		||||
            }
 | 
			
		||||
            return parseVersion(res.stdout);
 | 
			
		||||
@@ -2156,7 +2184,7 @@ exports.parseVersion = parseVersion;
 | 
			
		||||
function isAvailable() {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        return yield exec.exec(`docker`, ['buildx'], true).then(res => {
 | 
			
		||||
            if (res.stderr != '' && !res.success) {
 | 
			
		||||
            if (res.stderr.length > 0 && !res.success) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            return res.success;
 | 
			
		||||
@@ -2164,21 +2192,56 @@ function isAvailable() {
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.isAvailable = isAvailable;
 | 
			
		||||
function platforms() {
 | 
			
		||||
function inspect(name) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        return yield exec.exec(`docker`, ['buildx', 'inspect'], true).then(res => {
 | 
			
		||||
            if (res.stderr != '' && !res.success) {
 | 
			
		||||
        return yield exec.exec(`docker`, ['buildx', 'inspect', name], true).then(res => {
 | 
			
		||||
            if (res.stderr.length > 0 && !res.success) {
 | 
			
		||||
                throw new Error(res.stderr);
 | 
			
		||||
            }
 | 
			
		||||
            for (const line of res.stdout.trim().split(`\n`)) {
 | 
			
		||||
                if (line.startsWith('Platforms')) {
 | 
			
		||||
                    return line.replace('Platforms: ', '').replace(/\s/g, '').trim();
 | 
			
		||||
            const builder = {};
 | 
			
		||||
            itlines: for (const line of res.stdout.trim().split(`\n`)) {
 | 
			
		||||
                const [key, ...rest] = line.split(':');
 | 
			
		||||
                const value = rest.map(v => v.trim()).join(':');
 | 
			
		||||
                if (key.length == 0 || value.length == 0) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                switch (key) {
 | 
			
		||||
                    case 'Name': {
 | 
			
		||||
                        if (builder.name == undefined) {
 | 
			
		||||
                            builder.name = value;
 | 
			
		||||
                        }
 | 
			
		||||
                        else {
 | 
			
		||||
                            builder.node_name = value;
 | 
			
		||||
                        }
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    case 'Driver': {
 | 
			
		||||
                        builder.driver = value;
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    case 'Endpoint': {
 | 
			
		||||
                        builder.node_endpoint = value;
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    case 'Status': {
 | 
			
		||||
                        builder.node_status = value;
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    case 'Flags': {
 | 
			
		||||
                        builder.node_flags = value;
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    case 'Platforms': {
 | 
			
		||||
                        builder.node_platforms = value.replace(/\s/g, '');
 | 
			
		||||
                        break itlines;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return builder;
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.platforms = platforms;
 | 
			
		||||
exports.inspect = inspect;
 | 
			
		||||
function install(inputVersion, dockerConfigHome) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const release = yield github.getRelease(inputVersion);
 | 
			
		||||
@@ -2254,6 +2317,28 @@ function filename(version) {
 | 
			
		||||
        return util.format('buildx-v%s.%s-%s%s', version, platform, arch, ext);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function getBuildKitVersion(containerID) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        return exec.exec(`docker`, ['inspect', '--format', '{{.Config.Image}}', containerID], true).then(bkitimage => {
 | 
			
		||||
            if (bkitimage.success && bkitimage.stdout.length > 0) {
 | 
			
		||||
                return exec.exec(`docker`, ['run', '--rm', bkitimage.stdout, '--version'], true).then(bkitversion => {
 | 
			
		||||
                    if (bkitversion.success && bkitversion.stdout.length > 0) {
 | 
			
		||||
                        return `${bkitimage.stdout} => ${bkitversion.stdout}`;
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (bkitversion.stderr.length > 0) {
 | 
			
		||||
                        core.warning(bkitversion.stderr);
 | 
			
		||||
                    }
 | 
			
		||||
                    return bkitversion.stdout;
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            else if (bkitimage.stderr.length > 0) {
 | 
			
		||||
                core.warning(bkitimage.stderr);
 | 
			
		||||
            }
 | 
			
		||||
            return bkitimage.stdout;
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
exports.getBuildKitVersion = getBuildKitVersion;
 | 
			
		||||
//# sourceMappingURL=buildx.js.map
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
@@ -5580,14 +5665,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
 | 
			
		||||
    return result;
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.setBuilderName = exports.builderName = exports.IsPost = void 0;
 | 
			
		||||
exports.setContainerName = exports.setBuilderName = exports.setDebug = exports.containerName = exports.builderName = exports.IsDebug = exports.IsPost = void 0;
 | 
			
		||||
const core = __importStar(__webpack_require__(186));
 | 
			
		||||
exports.IsPost = !!process.env['STATE_isPost'];
 | 
			
		||||
exports.IsDebug = !!process.env['STATE_isDebug'];
 | 
			
		||||
exports.builderName = process.env['STATE_builderName'] || '';
 | 
			
		||||
exports.containerName = process.env['STATE_containerName'] || '';
 | 
			
		||||
function setDebug(debug) {
 | 
			
		||||
    core.saveState('isDebug', debug);
 | 
			
		||||
}
 | 
			
		||||
exports.setDebug = setDebug;
 | 
			
		||||
function setBuilderName(builderName) {
 | 
			
		||||
    core.saveState('builderName', builderName);
 | 
			
		||||
}
 | 
			
		||||
exports.setBuilderName = setBuilderName;
 | 
			
		||||
function setContainerName(containerName) {
 | 
			
		||||
    core.saveState('containerName', containerName);
 | 
			
		||||
}
 | 
			
		||||
exports.setContainerName = setContainerName;
 | 
			
		||||
if (!exports.IsPost) {
 | 
			
		||||
    core.saveState('isPost', 'true');
 | 
			
		||||
}
 | 
			
		||||
@@ -8007,9 +8102,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
Object.defineProperty(exports, "__esModule", { value: true });
 | 
			
		||||
exports.asyncForEach = exports.getInputList = exports.getInputs = exports.osArch = exports.osPlat = void 0;
 | 
			
		||||
exports.setOutput = exports.asyncForEach = exports.getInputList = exports.getInputs = exports.osArch = exports.osPlat = void 0;
 | 
			
		||||
const os = __importStar(__webpack_require__(87));
 | 
			
		||||
const core = __importStar(__webpack_require__(186));
 | 
			
		||||
const command_1 = __webpack_require__(351);
 | 
			
		||||
exports.osPlat = os.platform();
 | 
			
		||||
exports.osArch = os.arch();
 | 
			
		||||
function getInputs() {
 | 
			
		||||
@@ -8022,7 +8118,8 @@ function getInputs() {
 | 
			
		||||
                '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
 | 
			
		||||
            install: /true/i.test(core.getInput('install')),
 | 
			
		||||
            use: /true/i.test(core.getInput('use')),
 | 
			
		||||
            endpoint: core.getInput('endpoint')
 | 
			
		||||
            endpoint: core.getInput('endpoint'),
 | 
			
		||||
            config: core.getInput('config')
 | 
			
		||||
        };
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
@@ -8045,6 +8142,11 @@ exports.asyncForEach = (array, callback) => __awaiter(void 0, void 0, void 0, fu
 | 
			
		||||
        yield callback(array[index], index, array);
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
 | 
			
		||||
function setOutput(name, value) {
 | 
			
		||||
    command_1.issueCommand('set-output', { name }, value);
 | 
			
		||||
}
 | 
			
		||||
exports.setOutput = setOutput;
 | 
			
		||||
//# sourceMappingURL=context.js.map
 | 
			
		||||
 | 
			
		||||
/***/ }),
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@
 | 
			
		||||
  ],
 | 
			
		||||
  "license": "Apache-2.0",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@actions/core": "^1.2.6",
 | 
			
		||||
    "@actions/core": "^1.2.7",
 | 
			
		||||
    "@actions/exec": "^1.0.4",
 | 
			
		||||
    "@actions/http-client": "^1.0.11",
 | 
			
		||||
    "@actions/tool-cache": "^1.6.1",
 | 
			
		||||
 
 | 
			
		||||
@@ -8,9 +8,19 @@ import * as github from './github';
 | 
			
		||||
import * as core from '@actions/core';
 | 
			
		||||
import * as tc from '@actions/tool-cache';
 | 
			
		||||
 | 
			
		||||
export type Builder = {
 | 
			
		||||
  name?: string;
 | 
			
		||||
  driver?: string;
 | 
			
		||||
  node_name?: string;
 | 
			
		||||
  node_endpoint?: string;
 | 
			
		||||
  node_status?: string;
 | 
			
		||||
  node_flags?: string;
 | 
			
		||||
  node_platforms?: string;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export async function getVersion(): Promise<string> {
 | 
			
		||||
  return await exec.exec(`docker`, ['buildx', 'version'], true).then(res => {
 | 
			
		||||
    if (res.stderr != '' && !res.success) {
 | 
			
		||||
    if (res.stderr.length > 0 && !res.success) {
 | 
			
		||||
      throw new Error(res.stderr);
 | 
			
		||||
    }
 | 
			
		||||
    return parseVersion(res.stdout);
 | 
			
		||||
@@ -27,23 +37,57 @@ export async function parseVersion(stdout: string): Promise<string> {
 | 
			
		||||
 | 
			
		||||
export async function isAvailable(): Promise<Boolean> {
 | 
			
		||||
  return await exec.exec(`docker`, ['buildx'], true).then(res => {
 | 
			
		||||
    if (res.stderr != '' && !res.success) {
 | 
			
		||||
    if (res.stderr.length > 0 && !res.success) {
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
    return res.success;
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function platforms(): Promise<String | undefined> {
 | 
			
		||||
  return await exec.exec(`docker`, ['buildx', 'inspect'], true).then(res => {
 | 
			
		||||
    if (res.stderr != '' && !res.success) {
 | 
			
		||||
export async function inspect(name: string): Promise<Builder> {
 | 
			
		||||
  return await exec.exec(`docker`, ['buildx', 'inspect', name], true).then(res => {
 | 
			
		||||
    if (res.stderr.length > 0 && !res.success) {
 | 
			
		||||
      throw new Error(res.stderr);
 | 
			
		||||
    }
 | 
			
		||||
    for (const line of res.stdout.trim().split(`\n`)) {
 | 
			
		||||
      if (line.startsWith('Platforms')) {
 | 
			
		||||
        return line.replace('Platforms: ', '').replace(/\s/g, '').trim();
 | 
			
		||||
    const builder: Builder = {};
 | 
			
		||||
    itlines: for (const line of res.stdout.trim().split(`\n`)) {
 | 
			
		||||
      const [key, ...rest] = line.split(':');
 | 
			
		||||
      const value = rest.map(v => v.trim()).join(':');
 | 
			
		||||
      if (key.length == 0 || value.length == 0) {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
      switch (key) {
 | 
			
		||||
        case 'Name': {
 | 
			
		||||
          if (builder.name == undefined) {
 | 
			
		||||
            builder.name = value;
 | 
			
		||||
          } else {
 | 
			
		||||
            builder.node_name = value;
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        case 'Driver': {
 | 
			
		||||
          builder.driver = value;
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        case 'Endpoint': {
 | 
			
		||||
          builder.node_endpoint = value;
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        case 'Status': {
 | 
			
		||||
          builder.node_status = value;
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        case 'Flags': {
 | 
			
		||||
          builder.node_flags = value;
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        case 'Platforms': {
 | 
			
		||||
          builder.node_platforms = value.replace(/\s/g, '');
 | 
			
		||||
          break itlines;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return builder;
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -127,3 +171,21 @@ async function filename(version: string): Promise<string> {
 | 
			
		||||
  const ext: string = context.osPlat == 'win32' ? '.exe' : '';
 | 
			
		||||
  return util.format('buildx-v%s.%s-%s%s', version, platform, arch, ext);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function getBuildKitVersion(containerID: string): Promise<string> {
 | 
			
		||||
  return exec.exec(`docker`, ['inspect', '--format', '{{.Config.Image}}', containerID], true).then(bkitimage => {
 | 
			
		||||
    if (bkitimage.success && bkitimage.stdout.length > 0) {
 | 
			
		||||
      return exec.exec(`docker`, ['run', '--rm', bkitimage.stdout, '--version'], true).then(bkitversion => {
 | 
			
		||||
        if (bkitversion.success && bkitversion.stdout.length > 0) {
 | 
			
		||||
          return `${bkitimage.stdout} => ${bkitversion.stdout}`;
 | 
			
		||||
        } else if (bkitversion.stderr.length > 0) {
 | 
			
		||||
          core.warning(bkitversion.stderr);
 | 
			
		||||
        }
 | 
			
		||||
        return bkitversion.stdout;
 | 
			
		||||
      });
 | 
			
		||||
    } else if (bkitimage.stderr.length > 0) {
 | 
			
		||||
      core.warning(bkitimage.stderr);
 | 
			
		||||
    }
 | 
			
		||||
    return bkitimage.stdout;
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
import * as os from 'os';
 | 
			
		||||
import * as core from '@actions/core';
 | 
			
		||||
import {issueCommand} from '@actions/core/lib/command';
 | 
			
		||||
 | 
			
		||||
export const osPlat: string = os.platform();
 | 
			
		||||
export const osArch: string = os.arch();
 | 
			
		||||
@@ -12,6 +13,7 @@ export interface Inputs {
 | 
			
		||||
  install: boolean;
 | 
			
		||||
  use: boolean;
 | 
			
		||||
  endpoint: string;
 | 
			
		||||
  config: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function getInputs(): Promise<Inputs> {
 | 
			
		||||
@@ -24,7 +26,8 @@ export async function getInputs(): Promise<Inputs> {
 | 
			
		||||
      '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host',
 | 
			
		||||
    install: /true/i.test(core.getInput('install')),
 | 
			
		||||
    use: /true/i.test(core.getInput('use')),
 | 
			
		||||
    endpoint: core.getInput('endpoint')
 | 
			
		||||
    endpoint: core.getInput('endpoint'),
 | 
			
		||||
    config: core.getInput('config')
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -47,3 +50,8 @@ export const asyncForEach = async (array, callback) => {
 | 
			
		||||
    await callback(array[index], index, array);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
 | 
			
		||||
export function setOutput(name: string, value: any): void {
 | 
			
		||||
  issueCommand('set-output', {name}, value);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										60
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								src/main.ts
									
									
									
									
									
								
							@@ -10,10 +10,10 @@ import * as stateHelper from './state-helper';
 | 
			
		||||
 | 
			
		||||
async function run(): Promise<void> {
 | 
			
		||||
  try {
 | 
			
		||||
    if (os.platform() !== 'linux') {
 | 
			
		||||
      core.setFailed('Only supported on linux platform');
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    core.startGroup(`Docker info`);
 | 
			
		||||
    await exec.exec('docker', ['version']);
 | 
			
		||||
    await exec.exec('docker', ['info']);
 | 
			
		||||
    core.endGroup();
 | 
			
		||||
 | 
			
		||||
    const inputs: context.Inputs = await context.getInputs();
 | 
			
		||||
    const dockerConfigHome: string = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker');
 | 
			
		||||
@@ -28,7 +28,7 @@ async function run(): Promise<void> {
 | 
			
		||||
    core.info(`Using buildx ${buildxVersion}`);
 | 
			
		||||
 | 
			
		||||
    const builderName: string = inputs.driver == 'docker' ? 'default' : `builder-${require('uuid').v4()}`;
 | 
			
		||||
    core.setOutput('name', builderName);
 | 
			
		||||
    context.setOutput('name', builderName);
 | 
			
		||||
    stateHelper.setBuilderName(builderName);
 | 
			
		||||
 | 
			
		||||
    if (inputs.driver !== 'docker') {
 | 
			
		||||
@@ -48,6 +48,9 @@ async function run(): Promise<void> {
 | 
			
		||||
      if (inputs.endpoint) {
 | 
			
		||||
        createArgs.push(inputs.endpoint);
 | 
			
		||||
      }
 | 
			
		||||
      if (inputs.config) {
 | 
			
		||||
        createArgs.push('--config', inputs.config);
 | 
			
		||||
      }
 | 
			
		||||
      await exec.exec('docker', createArgs);
 | 
			
		||||
      core.endGroup();
 | 
			
		||||
 | 
			
		||||
@@ -66,25 +69,50 @@ async function run(): Promise<void> {
 | 
			
		||||
      core.endGroup();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    core.startGroup(`Extracting available platforms`);
 | 
			
		||||
    const platforms = await buildx.platforms();
 | 
			
		||||
    core.info(`${platforms}`);
 | 
			
		||||
    core.setOutput('platforms', platforms);
 | 
			
		||||
    core.startGroup(`Inspect builder`);
 | 
			
		||||
    const builder = await buildx.inspect(builderName);
 | 
			
		||||
    core.info(JSON.stringify(builder, undefined, 2));
 | 
			
		||||
    context.setOutput('driver', builder.driver);
 | 
			
		||||
    context.setOutput('endpoint', builder.node_endpoint);
 | 
			
		||||
    context.setOutput('status', builder.node_status);
 | 
			
		||||
    context.setOutput('flags', builder.node_flags);
 | 
			
		||||
    context.setOutput('platforms', builder.node_platforms);
 | 
			
		||||
    core.endGroup();
 | 
			
		||||
 | 
			
		||||
    if (inputs.driver == 'docker-container') {
 | 
			
		||||
      stateHelper.setContainerName(`buildx_buildkit_${builder.node_name}`);
 | 
			
		||||
      core.startGroup(`BuildKit version`);
 | 
			
		||||
      core.info(await buildx.getBuildKitVersion(`buildx_buildkit_${builder.node_name}`));
 | 
			
		||||
      core.endGroup();
 | 
			
		||||
    }
 | 
			
		||||
    if (core.isDebug() || builder.node_flags?.includes('--debug')) {
 | 
			
		||||
      stateHelper.setDebug('true');
 | 
			
		||||
    }
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    core.setFailed(error.message);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function cleanup(): Promise<void> {
 | 
			
		||||
  if (stateHelper.builderName.length == 0) {
 | 
			
		||||
    return;
 | 
			
		||||
  if (stateHelper.IsDebug && stateHelper.containerName.length > 0) {
 | 
			
		||||
    core.startGroup(`BuildKit container logs`);
 | 
			
		||||
    await mexec.exec('docker', ['logs', `${stateHelper.containerName}`], false).then(res => {
 | 
			
		||||
      if (res.stderr.length > 0 && !res.success) {
 | 
			
		||||
        core.warning(res.stderr);
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
    core.endGroup();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (stateHelper.builderName.length > 0) {
 | 
			
		||||
    core.startGroup(`Removing builder`);
 | 
			
		||||
    await mexec.exec('docker', ['buildx', 'rm', `${stateHelper.builderName}`], false).then(res => {
 | 
			
		||||
      if (res.stderr.length > 0 && !res.success) {
 | 
			
		||||
        core.warning(res.stderr);
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
    core.endGroup();
 | 
			
		||||
  }
 | 
			
		||||
  await mexec.exec('docker', ['buildx', 'rm', `${stateHelper.builderName}`], false).then(res => {
 | 
			
		||||
    if (res.stderr != '' && !res.success) {
 | 
			
		||||
      core.warning(res.stderr);
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if (!stateHelper.IsPost) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,22 @@
 | 
			
		||||
import * as core from '@actions/core';
 | 
			
		||||
 | 
			
		||||
export const IsPost = !!process.env['STATE_isPost'];
 | 
			
		||||
export const IsDebug = !!process.env['STATE_isDebug'];
 | 
			
		||||
export const builderName = process.env['STATE_builderName'] || '';
 | 
			
		||||
export const containerName = process.env['STATE_containerName'] || '';
 | 
			
		||||
 | 
			
		||||
export function setDebug(debug: string) {
 | 
			
		||||
  core.saveState('isDebug', debug);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function setBuilderName(builderName: string) {
 | 
			
		||||
  core.saveState('builderName', builderName);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function setContainerName(containerName: string) {
 | 
			
		||||
  core.saveState('containerName', containerName);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if (!IsPost) {
 | 
			
		||||
  core.saveState('isPost', 'true');
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,10 @@
 | 
			
		||||
# yarn lockfile v1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
"@actions/core@^1.2.6":
 | 
			
		||||
  version "1.2.6"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
 | 
			
		||||
  integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
 | 
			
		||||
"@actions/core@^1.2.6", "@actions/core@^1.2.7":
 | 
			
		||||
  version "1.2.7"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.7.tgz#594f8c45b213f0146e4be7eda8ae5cf4e198e5ab"
 | 
			
		||||
  integrity sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig==
 | 
			
		||||
 | 
			
		||||
"@actions/exec@^1.0.0", "@actions/exec@^1.0.4":
 | 
			
		||||
  version "1.0.4"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user