mirror of
				https://gitea.com/docker/build-push-action.git
				synced 2025-10-31 00:58:18 +07:00 
			
		
		
		
	
						commit
						3f08c86128
					
				
							
								
								
									
										15
									
								
								.editorconfig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								.editorconfig
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| # This file is for unifying the coding style for different editors and IDEs. | ||||
| # More information at http://editorconfig.org | ||||
| 
 | ||||
| root = true | ||||
| 
 | ||||
| [*] | ||||
| indent_style = space | ||||
| indent_size = 2 | ||||
| end_of_line = lf | ||||
| charset = utf-8 | ||||
| trim_trailing_whitespace = true | ||||
| insert_final_newline = true | ||||
| 
 | ||||
| [*.md] | ||||
| trim_trailing_whitespace = false | ||||
							
								
								
									
										166
									
								
								.github/workflows/setup-buildx-ci.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										166
									
								
								.github/workflows/setup-buildx-ci.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,166 @@ | ||||
| name: setup-buildx-ci | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - master | ||||
|       - v2-working-branch # remove when merged to master | ||||
|     paths: | ||||
|       - .github/workflows/setup-buildx-ci.yml | ||||
|       - setup-buildx/** | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - master | ||||
|       - v2-working-branch # remove when merged to master | ||||
|     paths: | ||||
|       - .github/workflows/setup-buildx-ci.yml | ||||
|       - setup-buildx/** | ||||
| 
 | ||||
| jobs: | ||||
|   main: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         buildx-version: | ||||
|           - latest | ||||
|           - v0.2.2 | ||||
|           - "" | ||||
|     steps: | ||||
|       - | ||||
|         name: Runner info | ||||
|         run: | | ||||
|           sudo apt-get install -y hwinfo | ||||
|           sudo hwinfo --short | ||||
|           sudo mount | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         id: buildx | ||||
|         uses: ./setup-buildx/ | ||||
|         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: Dump context | ||||
|         uses: crazy-max/ghaction-dump-context@v1 | ||||
| 
 | ||||
|   multi: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Set up Docker Buildx 1 | ||||
|         id: buildx1 | ||||
|         uses: ./setup-buildx/ | ||||
|       - | ||||
|         name: Builder 1 instance name | ||||
|         run: echo ${{ steps.buildx1.outputs.name }} | ||||
|       - | ||||
|         name: Set up Docker Buildx 2 | ||||
|         id: buildx2 | ||||
|         uses: ./setup-buildx/ | ||||
|       - | ||||
|         name: Builder 2 instance name | ||||
|         run: echo ${{ steps.buildx2.outputs.name }} | ||||
| 
 | ||||
|   install: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: ./setup-buildx/ | ||||
|         with: | ||||
|           install: true | ||||
|       - | ||||
|         name: Check cmd | ||||
|         run: | | ||||
|           docker build --help | ||||
| 
 | ||||
|   use: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         use: | ||||
|           - true | ||||
|           - false | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         id: buildx | ||||
|         uses: ./setup-buildx/ | ||||
|         with: | ||||
|           use: ${{ matrix.use }} | ||||
|       - | ||||
|         name: List builder instances | ||||
|         run: docker buildx ls | ||||
| 
 | ||||
|   driver: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         driver-opt: | ||||
|           - image=moby/buildkit:latest | ||||
|           - image=moby/buildkit:master | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         id: buildx | ||||
|         uses: ./setup-buildx/ | ||||
|         with: | ||||
|           driver: docker-container | ||||
|           driver-opt: ${{ matrix.driver-opt }} | ||||
| 
 | ||||
|   with-qemu: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         buildx-version: | ||||
|           - latest | ||||
|           - v0.2.2 | ||||
|           - "" | ||||
|         qemu-platforms: | ||||
|           - all | ||||
|           - arm64,riscv64,arm | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: ./setup-qemu/ | ||||
|         with: | ||||
|           platforms: ${{ matrix.qemu-platforms }} | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         id: buildx | ||||
|         uses: ./setup-buildx/ | ||||
|         with: | ||||
|           version: ${{ matrix.buildx-version }} | ||||
|       - | ||||
|         name: Available platforms | ||||
|         run: echo ${{ steps.buildx.outputs.platforms }} | ||||
|       - | ||||
|         name: Builder instance name | ||||
|         run: echo ${{ steps.buildx.outputs.name }} | ||||
							
								
								
									
										38
									
								
								.github/workflows/setup-buildx-precheckin.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								.github/workflows/setup-buildx-precheckin.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| name: setup-buildx-precheckin | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - master | ||||
|       - v2-working-branch # remove when merged to master | ||||
|     paths: | ||||
|       - .github/workflows/setup-buildx-precheckin.yml | ||||
|       - setup-buildx/** | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - master | ||||
|       - v2-working-branch # remove when merged to master | ||||
|     paths: | ||||
|       - .github/workflows/setup-buildx-precheckin.yml | ||||
|       - setup-buildx/** | ||||
| 
 | ||||
| jobs: | ||||
|   pre-checkin: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Install | ||||
|         run: yarn --cwd ./setup-buildx/ install | ||||
|       - | ||||
|         name: Pre-checkin | ||||
|         run: yarn --cwd ./setup-buildx/ run pre-checkin | ||||
|       - | ||||
|         name: Check for uncommitted changes | ||||
|         run: | | ||||
|           if [[ `git status --porcelain` ]]; then | ||||
|             git status --porcelain | ||||
|             echo "::warning::Found changes. Please run 'yarn --cwd ./setup-buildx/ run pre-checkin' and push" | ||||
|           fi | ||||
							
								
								
									
										38
									
								
								.github/workflows/setup-buildx-test.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								.github/workflows/setup-buildx-test.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| name: setup-buildx-test | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - master | ||||
|       - v2-working-branch # remove when merged to master | ||||
|     paths: | ||||
|       - .github/workflows/setup-buildx-test.yml | ||||
|       - setup-buildx/** | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - master | ||||
|       - v2-working-branch # remove when merged to master | ||||
|     paths: | ||||
|       - .github/workflows/setup-buildx-test.yml | ||||
|       - setup-buildx/** | ||||
| 
 | ||||
| jobs: | ||||
|   test: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Install | ||||
|         run: yarn --cwd ./setup-buildx/ install | ||||
|       - | ||||
|         name: Test | ||||
|         run: yarn --cwd ./setup-buildx/ run test | ||||
| #      - | ||||
| #        name: Upload coverage | ||||
| #        uses: codecov/codecov-action@v1.0.7 | ||||
| #        if: success() | ||||
| #        with: | ||||
| #          token: ${{ secrets.CODECOV_TOKEN }} | ||||
| #          file: ./coverage/clover.xml | ||||
							
								
								
									
										53
									
								
								.github/workflows/setup-qemu-ci.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								.github/workflows/setup-qemu-ci.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,53 @@ | ||||
| name: setup-qemu-ci | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - master | ||||
|       - v2-working-branch # remove when merged to master | ||||
|     paths: | ||||
|       - .github/workflows/setup-qemu-ci.yml | ||||
|       - setup-qemu/** | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - master | ||||
|       - v2-working-branch # remove when merged to master | ||||
|     paths: | ||||
|       - .github/workflows/setup-qemu-ci.yml | ||||
|       - setup-qemu/** | ||||
| 
 | ||||
| jobs: | ||||
|   main: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         image: | ||||
|           - tonistiigi/binfmt:latest | ||||
|           - tonistiigi/binfmt:master | ||||
|         platforms: | ||||
|           - all | ||||
|           - arm64,riscv64,arm | ||||
|     steps: | ||||
|       - | ||||
|         name: Runner info | ||||
|         run: | | ||||
|           sudo apt-get install -y hwinfo | ||||
|           sudo hwinfo --short | ||||
|           sudo mount | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         id: qemu | ||||
|         uses: ./setup-qemu/ | ||||
|         with: | ||||
|           image: ${{ matrix.image }} | ||||
|           platforms: ${{ matrix.platforms }} | ||||
|       - | ||||
|         name: Available platforms | ||||
|         run: echo ${{ steps.qemu.outputs.platforms }} | ||||
|       - | ||||
|         name: Dump context | ||||
|         uses: crazy-max/ghaction-dump-context@v1 | ||||
							
								
								
									
										38
									
								
								.github/workflows/setup-qemu-precheckin.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								.github/workflows/setup-qemu-precheckin.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| name: setup-qemu-precheckin | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - master | ||||
|       - v2-working-branch # remove when merged to master | ||||
|     paths: | ||||
|       - .github/workflows/setup-qemu-precheckin.yml | ||||
|       - setup-qemu/** | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - master | ||||
|       - v2-working-branch # remove when merged to master | ||||
|     paths: | ||||
|       - .github/workflows/setup-qemu-precheckin.yml | ||||
|       - setup-qemu/** | ||||
| 
 | ||||
| jobs: | ||||
|   pre-checkin: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Install | ||||
|         run: yarn --cwd ./setup-qemu/ install | ||||
|       - | ||||
|         name: Pre-checkin | ||||
|         run: yarn --cwd ./setup-qemu/ run pre-checkin | ||||
|       - | ||||
|         name: Check for uncommitted changes | ||||
|         run: | | ||||
|           if [[ `git status --porcelain` ]]; then | ||||
|             git status --porcelain | ||||
|             echo "::warning::Found changes. Please run 'yarn --cwd ./setup-qemu/ run pre-checkin' and push" | ||||
|           fi | ||||
							
								
								
									
										2
									
								
								setup-buildx/.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								setup-buildx/.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| /dist/** linguist-generated=true | ||||
| /lib/** linguist-generated=true | ||||
							
								
								
									
										95
									
								
								setup-buildx/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								setup-buildx/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,95 @@ | ||||
| node_modules | ||||
| lib | ||||
| 
 | ||||
| # Jetbrains | ||||
| /.idea | ||||
| /*.iml | ||||
| 
 | ||||
| # Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore | ||||
| # Logs | ||||
| logs | ||||
| *.log | ||||
| npm-debug.log* | ||||
| yarn-debug.log* | ||||
| yarn-error.log* | ||||
| lerna-debug.log* | ||||
| 
 | ||||
| # Diagnostic reports (https://nodejs.org/api/report.html) | ||||
| report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||||
| 
 | ||||
| # Runtime data | ||||
| pids | ||||
| *.pid | ||||
| *.seed | ||||
| *.pid.lock | ||||
| 
 | ||||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||||
| lib-cov | ||||
| 
 | ||||
| # Coverage directory used by tools like istanbul | ||||
| coverage | ||||
| *.lcov | ||||
| 
 | ||||
| # nyc test coverage | ||||
| .nyc_output | ||||
| 
 | ||||
| # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||||
| .grunt | ||||
| 
 | ||||
| # Bower dependency directory (https://bower.io/) | ||||
| bower_components | ||||
| 
 | ||||
| # node-waf configuration | ||||
| .lock-wscript | ||||
| 
 | ||||
| # Compiled binary addons (https://nodejs.org/api/addons.html) | ||||
| build/Release | ||||
| 
 | ||||
| # Dependency directories | ||||
| jspm_packages/ | ||||
| 
 | ||||
| # TypeScript v1 declaration files | ||||
| typings/ | ||||
| 
 | ||||
| # TypeScript cache | ||||
| *.tsbuildinfo | ||||
| 
 | ||||
| # Optional npm cache directory | ||||
| .npm | ||||
| 
 | ||||
| # Optional eslint cache | ||||
| .eslintcache | ||||
| 
 | ||||
| # Optional REPL history | ||||
| .node_repl_history | ||||
| 
 | ||||
| # Output of 'npm pack' | ||||
| *.tgz | ||||
| 
 | ||||
| # Yarn Integrity file | ||||
| .yarn-integrity | ||||
| 
 | ||||
| # dotenv environment variables file | ||||
| .env | ||||
| .env.test | ||||
| 
 | ||||
| # parcel-bundler cache (https://parceljs.org/) | ||||
| .cache | ||||
| 
 | ||||
| # next.js build output | ||||
| .next | ||||
| 
 | ||||
| # nuxt.js build output | ||||
| .nuxt | ||||
| 
 | ||||
| # vuepress build output | ||||
| .vuepress/dist | ||||
| 
 | ||||
| # Serverless directories | ||||
| .serverless/ | ||||
| 
 | ||||
| # FuseBox cache | ||||
| .fusebox/ | ||||
| 
 | ||||
| # DynamoDB Local files | ||||
| .dynamodb/ | ||||
							
								
								
									
										11
									
								
								setup-buildx/.prettierrc.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								setup-buildx/.prettierrc.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| { | ||||
|   "printWidth": 120, | ||||
|   "tabWidth": 2, | ||||
|   "useTabs": false, | ||||
|   "semi": true, | ||||
|   "singleQuote": true, | ||||
|   "trailingComma": "none", | ||||
|   "bracketSpacing": false, | ||||
|   "arrowParens": "avoid", | ||||
|   "parser": "typescript" | ||||
| } | ||||
							
								
								
									
										121
									
								
								setup-buildx/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										121
									
								
								setup-buildx/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,121 @@ | ||||
| ## About | ||||
| 
 | ||||
| GitHub Action to set up Docker [Buildx](https://github.com/docker/buildx). | ||||
| 
 | ||||
| ___ | ||||
| 
 | ||||
| * [Usage](#usage) | ||||
|   * [Quick start](#quick-start) | ||||
|   * [With QEMU](#with-qemu) | ||||
| * [Customizing](#customizing) | ||||
|   * [inputs](#inputs) | ||||
|   * [outputs](#outputs) | ||||
|   * [environment variables](#environment-variables) | ||||
| * [Limitation](#limitation) | ||||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| ### Quick start | ||||
| 
 | ||||
| ```yaml | ||||
| name: ci | ||||
| 
 | ||||
| on: | ||||
|   pull_request: | ||||
|     branches: master | ||||
|   push: | ||||
|     branches: master | ||||
|     tags: | ||||
| 
 | ||||
| jobs: | ||||
|   buildx: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         id: buildx | ||||
|         uses: docker/actions/setup-buildx@v1 | ||||
|         with: | ||||
|           version: latest | ||||
|       - | ||||
|         name: Builder instance name | ||||
|         run: echo ${{ steps.buildx.outputs.name }} | ||||
|       - | ||||
|         name: Available platforms | ||||
|         run: echo ${{ steps.buildx.outputs.platforms }} | ||||
| ``` | ||||
| 
 | ||||
| ### With QEMU | ||||
| 
 | ||||
| If you want support for more platforms you can use our [setup-qemu](../setup-qemu) action: | ||||
| 
 | ||||
| ```yaml | ||||
| name: ci | ||||
| 
 | ||||
| on: | ||||
|   pull_request: | ||||
|     branches: master | ||||
|   push: | ||||
|     branches: master | ||||
|     tags: | ||||
| 
 | ||||
| jobs: | ||||
|   buildx: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/actions/setup-qemu@v1 | ||||
|         with: | ||||
|           platforms: all | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         id: buildx | ||||
|         uses: docker/actions/setup-buildx@v1 | ||||
|         with: | ||||
|           version: latest | ||||
|       - | ||||
|         name: Available platforms | ||||
|         run: echo ${{ steps.buildx.outputs.platforms }} | ||||
| ``` | ||||
| 
 | ||||
| ## Customizing | ||||
| 
 | ||||
| ### inputs | ||||
| 
 | ||||
| Following inputs can be used as `step.with` keys | ||||
| 
 | ||||
| | Name             | Type    | Default                           | Description                        | | ||||
| |------------------|---------|-----------------------------------|------------------------------------| | ||||
| | `version`        | String  | _the one installed on the runner_ | [Buildx](https://github.com/docker/buildx) version. e.g. `v0.3.0`, `latest` | | ||||
| | `driver`         | String  | `docker-container`                | Sets the [builder driver](https://github.com/docker/buildx#--driver-driver) to be used. | | ||||
| | `driver-opt`     | String  |                                   | Passes additional [driver-specific options](https://github.com/docker/buildx#--driver-opt-options). e.g. `image=moby/buildkit:master` | | ||||
| | `install`        | Bool    | `false`                           | Sets up `docker build` command as an alias to `docker buildx` | | ||||
| | `use`            | Bool    | `true`                            | Switch to this builder instance | | ||||
| 
 | ||||
| ### outputs | ||||
| 
 | ||||
| Following outputs are available | ||||
| 
 | ||||
| | Name          | Type    | Description                           | | ||||
| |---------------|---------|---------------------------------------| | ||||
| | `name`        | String  | Builder instance name | | ||||
| | `platforms`   | String  | Available platforms (comma separated) | | ||||
| 
 | ||||
| ### environment variables | ||||
| 
 | ||||
| The following [official docker environment variables](https://docs.docker.com/engine/reference/commandline/cli/#environment-variables) are supported: | ||||
| 
 | ||||
| | Name            | Type    | Default      | Description                                    | | ||||
| |-----------------|---------|-------------|-------------------------------------------------| | ||||
| | `DOCKER_CONFIG` | String  | `~/.docker` | The location of your client configuration files | | ||||
| 
 | ||||
| ## 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). | ||||
							
								
								
									
										37
									
								
								setup-buildx/__tests__/buildx.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								setup-buildx/__tests__/buildx.test.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| import fs = require('fs'); | ||||
| import * as buildx from '../src/buildx'; | ||||
| import * as path from 'path'; | ||||
| import * as os from 'os'; | ||||
| 
 | ||||
| const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-')); | ||||
| 
 | ||||
| describe('buildx', () => { | ||||
|   it('is available', async () => { | ||||
|     expect(await buildx.isAvailable()).toBe(true); | ||||
|   }); | ||||
| 
 | ||||
|   it('count builders', async () => { | ||||
|     const countBuilders = await buildx.countBuilders(); | ||||
|     console.log(`countBuilders: ${countBuilders}`); | ||||
|     expect(countBuilders).toBeGreaterThan(0); | ||||
|   }); | ||||
| 
 | ||||
|   it('platforms', async () => { | ||||
|     const platforms = await buildx.platforms(); | ||||
|     console.log(`platforms: ${platforms}`); | ||||
|     expect(platforms).not.toBeUndefined(); | ||||
|     expect(platforms).not.toEqual(''); | ||||
|   }); | ||||
| 
 | ||||
|   it('acquires v0.2.2 version of buildx', async () => { | ||||
|     const buildxBin = await buildx.install('v0.2.2', tmpDir); | ||||
|     console.log(buildxBin); | ||||
|     expect(fs.existsSync(buildxBin)).toBe(true); | ||||
|   }, 100000); | ||||
| 
 | ||||
|   it('acquires latest version of buildx', async () => { | ||||
|     const buildxBin = await buildx.install('latest', tmpDir); | ||||
|     console.log(buildxBin); | ||||
|     expect(fs.existsSync(buildxBin)).toBe(true); | ||||
|   }, 100000); | ||||
| }); | ||||
							
								
								
									
										17
									
								
								setup-buildx/__tests__/github.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								setup-buildx/__tests__/github.test.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | ||||
| import * as github from '../src/github'; | ||||
| 
 | ||||
| describe('github', () => { | ||||
|   it('returns latest buildx GitHub release', async () => { | ||||
|     const release = await github.getRelease('latest'); | ||||
|     console.log(release); | ||||
|     expect(release).not.toBeNull(); | ||||
|     expect(release?.tag_name).not.toEqual(''); | ||||
|   }); | ||||
| 
 | ||||
|   it('returns v0.2.2 buildx GitHub release', async () => { | ||||
|     const release = await github.getRelease('v0.2.2'); | ||||
|     console.log(release); | ||||
|     expect(release).not.toBeNull(); | ||||
|     expect(release?.tag_name).toEqual('v0.2.2'); | ||||
|   }); | ||||
| }); | ||||
							
								
								
									
										38
									
								
								setup-buildx/action.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								setup-buildx/action.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| # https://help.github.com/en/articles/metadata-syntax-for-github-actions | ||||
| name: 'Docker - Setup Buildx' | ||||
| description: 'GitHub Action to set up Docker Buildx' | ||||
| author: 'crazy-max' | ||||
| branding: | ||||
|   color: 'blue' | ||||
|   icon: 'truck' | ||||
| 
 | ||||
| inputs: | ||||
|   version: | ||||
|     description: 'Buildx version. e.g. v0.3.0' | ||||
|     required: false | ||||
|   driver: | ||||
|     description: 'Sets the builder driver to be used' | ||||
|     default: 'docker-container' | ||||
|     required: false | ||||
|   driver-opt: | ||||
|     description: 'Passes additional driver-specific options. Eg. image=moby/buildkit:master' | ||||
|     required: false | ||||
|   install: | ||||
|     description: 'Sets up docker build command as an alias to docker buildx' | ||||
|     default: 'false' | ||||
|     required: false | ||||
|   use: | ||||
|     description: 'Switch to this builder instance' | ||||
|     default: 'true' | ||||
|     required: false | ||||
| 
 | ||||
| outputs: | ||||
|   name: | ||||
|     description: 'Builder instance name' | ||||
|   platforms: | ||||
|     description: 'Available platforms (comma separated)' | ||||
| 
 | ||||
| runs: | ||||
|   using: 'node12' | ||||
|   main: 'dist/index.js' | ||||
|   post: 'dist/index.js' | ||||
							
								
								
									
										7546
									
								
								setup-buildx/dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7546
									
								
								setup-buildx/dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										12
									
								
								setup-buildx/jest.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								setup-buildx/jest.config.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| module.exports = { | ||||
|   clearMocks: true, | ||||
|   moduleFileExtensions: ['js', 'ts'], | ||||
|   setupFiles: ["dotenv/config"], | ||||
|   testEnvironment: 'node', | ||||
|   testMatch: ['**/*.test.ts'], | ||||
|   testRunner: 'jest-circus/runner', | ||||
|   transform: { | ||||
|     '^.+\\.ts$': 'ts-jest' | ||||
|   }, | ||||
|   verbose: false | ||||
| } | ||||
							
								
								
									
										44
									
								
								setup-buildx/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								setup-buildx/package.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,44 @@ | ||||
| { | ||||
|   "name": "setup-buildx", | ||||
|   "description": "GitHub Action to set up Docker Buildx", | ||||
|   "main": "lib/main.js", | ||||
|   "scripts": { | ||||
|     "build": "tsc && ncc build", | ||||
|     "format": "prettier --write **/*.ts", | ||||
|     "format-check": "prettier --check **/*.ts", | ||||
|     "test": "jest --coverage", | ||||
|     "pre-checkin": "yarn run format && yarn run build" | ||||
|   }, | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "git+https://github.com/docker/actions.git", | ||||
|     "directory": "setup-buildx" | ||||
|   }, | ||||
|   "keywords": [ | ||||
|     "actions", | ||||
|     "docker", | ||||
|     "buildx" | ||||
|   ], | ||||
|   "author": "CrazyMax", | ||||
|   "license": "Apache-2.0", | ||||
|   "dependencies": { | ||||
|     "@actions/core": "^1.2.4", | ||||
|     "@actions/exec": "^1.0.4", | ||||
|     "@actions/http-client": "^1.0.8", | ||||
|     "@actions/tool-cache": "^1.5.5", | ||||
|     "semver": "^7.3.2" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/jest": "^26.0.3", | ||||
|     "@types/node": "^14.0.14", | ||||
|     "@zeit/ncc": "^0.22.3", | ||||
|     "dotenv": "^8.2.0", | ||||
|     "jest": "^26.1.0", | ||||
|     "jest-circus": "^26.1.0", | ||||
|     "jest-runtime": "^26.1.0", | ||||
|     "prettier": "^2.0.5", | ||||
|     "ts-jest": "^26.1.1", | ||||
|     "typescript": "^3.9.5", | ||||
|     "typescript-formatter": "^7.2.2" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										98
									
								
								setup-buildx/src/buildx.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								setup-buildx/src/buildx.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,98 @@ | ||||
| import * as fs from 'fs'; | ||||
| import * as os from 'os'; | ||||
| import * as path from 'path'; | ||||
| import * as semver from 'semver'; | ||||
| import * as util from 'util'; | ||||
| import * as exec from './exec'; | ||||
| import * as github from './github'; | ||||
| import * as core from '@actions/core'; | ||||
| import * as tc from '@actions/tool-cache'; | ||||
| 
 | ||||
| const osPlat: string = os.platform(); | ||||
| 
 | ||||
| export async function isAvailable(): Promise<Boolean> { | ||||
|   return await exec.exec(`docker`, ['buildx'], true).then(res => { | ||||
|     if (res.stderr != '' && !res.success) { | ||||
|       return false; | ||||
|     } | ||||
|     return res.success; | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| export async function countBuilders(): Promise<number> { | ||||
|   return await exec.exec(`docker`, ['buildx', 'ls'], true).then(res => { | ||||
|     if (res.stderr != '' && !res.success) { | ||||
|       throw new Error(`Cannot list builders: ${res.stderr}`); | ||||
|     } | ||||
|     return (res.stdout.trim().split(`\n`).length - 1) / 2; | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| export async function platforms(): Promise<String | undefined> { | ||||
|   return await exec.exec(`docker`, ['buildx', 'inspect'], true).then(res => { | ||||
|     if (res.stderr != '' && !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(); | ||||
|       } | ||||
|     } | ||||
|   }); | ||||
| } | ||||
| 
 | ||||
| export async function install(inputVersion: string, dockerConfigHome: string): Promise<string> { | ||||
|   const release: github.GitHubRelease | null = await github.getRelease(inputVersion); | ||||
|   if (!release) { | ||||
|     throw new Error(`Cannot find buildx ${inputVersion} release`); | ||||
|   } | ||||
|   core.debug(`Release found: ${release.tag_name}`); | ||||
|   const version = release.tag_name.replace(/^v+|v+$/g, ''); | ||||
| 
 | ||||
|   let toolPath: string; | ||||
|   toolPath = tc.find('buildx', version); | ||||
|   if (!toolPath) { | ||||
|     const c = semver.clean(version) || ''; | ||||
|     if (!semver.valid(c)) { | ||||
|       throw new Error(`Invalid Buildx version "${version}".`); | ||||
|     } | ||||
|     toolPath = await download(version); | ||||
|   } | ||||
| 
 | ||||
|   const pluginsDir: string = path.join(dockerConfigHome, 'cli-plugins'); | ||||
|   core.debug(`Plugins dir is ${pluginsDir}`); | ||||
|   if (!fs.existsSync(pluginsDir)) { | ||||
|     fs.mkdirSync(pluginsDir, {recursive: true}); | ||||
|   } | ||||
| 
 | ||||
|   const filename: string = osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx'; | ||||
|   const pluginPath: string = path.join(pluginsDir, filename); | ||||
|   core.debug(`Plugin path is ${pluginPath}`); | ||||
|   fs.copyFileSync(path.join(toolPath, filename), pluginPath); | ||||
| 
 | ||||
|   core.info('🔨 Fixing perms...'); | ||||
|   fs.chmodSync(pluginPath, '0755'); | ||||
| 
 | ||||
|   return pluginPath; | ||||
| } | ||||
| 
 | ||||
| async function download(version: string): Promise<string> { | ||||
|   version = semver.clean(version) || ''; | ||||
|   const platform: string = osPlat == 'win32' ? 'windows' : osPlat; | ||||
|   const ext: string = osPlat == 'win32' ? '.exe' : ''; | ||||
|   const filename: string = util.format('buildx-v%s.%s-amd64%s', version, platform, ext); | ||||
|   const targetFile: string = osPlat == 'win32' ? 'docker-buildx.exe' : 'docker-buildx'; | ||||
| 
 | ||||
|   const downloadUrl = util.format('https://github.com/docker/buildx/releases/download/v%s/%s', version, filename); | ||||
|   let downloadPath: string; | ||||
| 
 | ||||
|   try { | ||||
|     core.info(`⬇️ Downloading ${downloadUrl}...`); | ||||
|     downloadPath = await tc.downloadTool(downloadUrl); | ||||
|     core.debug(`Downloaded to ${downloadPath}`); | ||||
|   } catch (error) { | ||||
|     throw error; | ||||
|   } | ||||
| 
 | ||||
|   return await tc.cacheFile(downloadPath, targetFile, 'buildx', version); | ||||
| } | ||||
							
								
								
									
										34
									
								
								setup-buildx/src/exec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								setup-buildx/src/exec.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | ||||
| import * as actionsExec from '@actions/exec'; | ||||
| import {ExecOptions} from '@actions/exec'; | ||||
| 
 | ||||
| export interface ExecResult { | ||||
|   success: boolean; | ||||
|   stdout: string; | ||||
|   stderr: string; | ||||
| } | ||||
| 
 | ||||
| export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => { | ||||
|   let stdout: string = ''; | ||||
|   let stderr: string = ''; | ||||
| 
 | ||||
|   const options: ExecOptions = { | ||||
|     silent: silent, | ||||
|     ignoreReturnCode: true | ||||
|   }; | ||||
|   options.listeners = { | ||||
|     stdout: (data: Buffer) => { | ||||
|       stdout += data.toString(); | ||||
|     }, | ||||
|     stderr: (data: Buffer) => { | ||||
|       stderr += data.toString(); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   const returnCode: number = await actionsExec.exec(command, args, options); | ||||
| 
 | ||||
|   return { | ||||
|     success: returnCode === 0, | ||||
|     stdout: stdout.trim(), | ||||
|     stderr: stderr.trim() | ||||
|   }; | ||||
| }; | ||||
							
								
								
									
										12
									
								
								setup-buildx/src/github.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								setup-buildx/src/github.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| import * as httpm from '@actions/http-client'; | ||||
| 
 | ||||
| export interface GitHubRelease { | ||||
|   id: number; | ||||
|   tag_name: string; | ||||
| } | ||||
| 
 | ||||
| export const getRelease = async (version: string): Promise<GitHubRelease | null> => { | ||||
|   const url: string = `https://github.com/docker/buildx/releases/${version}`; | ||||
|   const http: httpm.HttpClient = new httpm.HttpClient('setup-buildx'); | ||||
|   return (await http.getJson<GitHubRelease>(url)).result; | ||||
| }; | ||||
							
								
								
									
										75
									
								
								setup-buildx/src/main.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								setup-buildx/src/main.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,75 @@ | ||||
| import * as os from 'os'; | ||||
| import * as path from 'path'; | ||||
| import * as buildx from './buildx'; | ||||
| import * as exec from './exec'; | ||||
| import * as stateHelper from './state-helper'; | ||||
| import * as core from '@actions/core'; | ||||
| 
 | ||||
| async function run(): Promise<void> { | ||||
|   try { | ||||
|     if (os.platform() !== 'linux') { | ||||
|       core.setFailed('Only supported on linux platform'); | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     const bxVersion: string = core.getInput('version'); | ||||
|     const bxDriver: string = core.getInput('driver') || 'docker-container'; | ||||
|     const bxDriverOpt: string = core.getInput('driver-opt'); | ||||
|     const bxInstall: boolean = /true/i.test(core.getInput('install')); | ||||
|     const bxUse: boolean = /true/i.test(core.getInput('use')); | ||||
| 
 | ||||
|     const dockerConfigHome: string = process.env.DOCKER_CONFIG || path.join(os.homedir(), '.docker'); | ||||
| 
 | ||||
|     if (!(await buildx.isAvailable()) || bxVersion) { | ||||
|       await buildx.install(bxVersion || 'latest', dockerConfigHome); | ||||
|     } | ||||
| 
 | ||||
|     core.info('📣 Buildx info'); | ||||
|     await exec.exec('docker', ['buildx', 'version'], false); | ||||
| 
 | ||||
|     const builderName: string = `builder-${(await buildx.countBuilders()) + 1}-${process.env.GITHUB_JOB}`; | ||||
|     core.setOutput('name', builderName); | ||||
|     stateHelper.setBuilderName(builderName); | ||||
| 
 | ||||
|     core.info('🔨 Creating a new builder instance...'); | ||||
|     let createArgs: Array<string> = ['buildx', 'create', '--name', builderName, '--driver', bxDriver]; | ||||
|     if (bxDriverOpt) { | ||||
|       createArgs.push('--driver-opt', bxDriverOpt); | ||||
|     } | ||||
|     if (bxUse) { | ||||
|       createArgs.push('--use'); | ||||
|     } | ||||
| 
 | ||||
|     await exec.exec('docker', createArgs, false); | ||||
| 
 | ||||
|     core.info('🏃 Booting builder...'); | ||||
|     await exec.exec('docker', ['buildx', 'inspect', '--bootstrap'], false); | ||||
| 
 | ||||
|     if (bxInstall) { | ||||
|       core.info('🤝 Setting buildx as default builder...'); | ||||
|       await exec.exec('docker', ['buildx', 'install'], false); | ||||
|     } | ||||
| 
 | ||||
|     core.info('🛒 Extracting available platforms...'); | ||||
|     const platforms = await buildx.platforms(); | ||||
|     core.info(`${platforms}`); | ||||
|     core.setOutput('platforms', platforms); | ||||
|   } catch (error) { | ||||
|     core.setFailed(error.message); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| async function cleanup(): Promise<void> { | ||||
|   try { | ||||
|     core.info('🚿 Removing builder instance...'); | ||||
|     await exec.exec('docker', ['buildx', 'rm', `${process.env.STATE_builderName}`], false); | ||||
|   } catch (error) { | ||||
|     core.warning(error.message); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| if (!stateHelper.IsPost) { | ||||
|   run(); | ||||
| } else { | ||||
|   cleanup(); | ||||
| } | ||||
							
								
								
									
										12
									
								
								setup-buildx/src/state-helper.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								setup-buildx/src/state-helper.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| import * as core from '@actions/core'; | ||||
| 
 | ||||
| export const IsPost = !!process.env['STATE_isPost']; | ||||
| export const builderName = !!process.env['STATE_builderName']; | ||||
| 
 | ||||
| export function setBuilderName(builderName: string) { | ||||
|   core.saveState('builderName', builderName); | ||||
| } | ||||
| 
 | ||||
| if (!IsPost) { | ||||
|   core.saveState('isPost', 'true'); | ||||
| } | ||||
							
								
								
									
										18
									
								
								setup-buildx/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								setup-buildx/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| { | ||||
|   "compilerOptions": { | ||||
|     "target": "es6", | ||||
|     "module": "commonjs", | ||||
|     "lib": [ | ||||
|       "es6", | ||||
|       "dom" | ||||
|     ], | ||||
|     "newLine": "lf", | ||||
|     "outDir": "./lib", | ||||
|     "rootDir": "./src", | ||||
|     "strict": true, | ||||
|     "noImplicitAny": false, | ||||
|     "esModuleInterop": true, | ||||
|     "sourceMap": true | ||||
|   }, | ||||
|   "exclude": ["node_modules", "**/*.test.ts"] | ||||
| } | ||||
							
								
								
									
										3779
									
								
								setup-buildx/yarn.lock
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3779
									
								
								setup-buildx/yarn.lock
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2
									
								
								setup-qemu/.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								setup-qemu/.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| /dist/** linguist-generated=true | ||||
| /lib/** linguist-generated=true | ||||
							
								
								
									
										95
									
								
								setup-qemu/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								setup-qemu/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,95 @@ | ||||
| node_modules | ||||
| lib | ||||
| 
 | ||||
| # Jetbrains | ||||
| /.idea | ||||
| /*.iml | ||||
| 
 | ||||
| # Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore | ||||
| # Logs | ||||
| logs | ||||
| *.log | ||||
| npm-debug.log* | ||||
| yarn-debug.log* | ||||
| yarn-error.log* | ||||
| lerna-debug.log* | ||||
| 
 | ||||
| # Diagnostic reports (https://nodejs.org/api/report.html) | ||||
| report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||||
| 
 | ||||
| # Runtime data | ||||
| pids | ||||
| *.pid | ||||
| *.seed | ||||
| *.pid.lock | ||||
| 
 | ||||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||||
| lib-cov | ||||
| 
 | ||||
| # Coverage directory used by tools like istanbul | ||||
| coverage | ||||
| *.lcov | ||||
| 
 | ||||
| # nyc test coverage | ||||
| .nyc_output | ||||
| 
 | ||||
| # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||||
| .grunt | ||||
| 
 | ||||
| # Bower dependency directory (https://bower.io/) | ||||
| bower_components | ||||
| 
 | ||||
| # node-waf configuration | ||||
| .lock-wscript | ||||
| 
 | ||||
| # Compiled binary addons (https://nodejs.org/api/addons.html) | ||||
| build/Release | ||||
| 
 | ||||
| # Dependency directories | ||||
| jspm_packages/ | ||||
| 
 | ||||
| # TypeScript v1 declaration files | ||||
| typings/ | ||||
| 
 | ||||
| # TypeScript cache | ||||
| *.tsbuildinfo | ||||
| 
 | ||||
| # Optional npm cache directory | ||||
| .npm | ||||
| 
 | ||||
| # Optional eslint cache | ||||
| .eslintcache | ||||
| 
 | ||||
| # Optional REPL history | ||||
| .node_repl_history | ||||
| 
 | ||||
| # Output of 'npm pack' | ||||
| *.tgz | ||||
| 
 | ||||
| # Yarn Integrity file | ||||
| .yarn-integrity | ||||
| 
 | ||||
| # dotenv environment variables file | ||||
| .env | ||||
| .env.test | ||||
| 
 | ||||
| # parcel-bundler cache (https://parceljs.org/) | ||||
| .cache | ||||
| 
 | ||||
| # next.js build output | ||||
| .next | ||||
| 
 | ||||
| # nuxt.js build output | ||||
| .nuxt | ||||
| 
 | ||||
| # vuepress build output | ||||
| .vuepress/dist | ||||
| 
 | ||||
| # Serverless directories | ||||
| .serverless/ | ||||
| 
 | ||||
| # FuseBox cache | ||||
| .fusebox/ | ||||
| 
 | ||||
| # DynamoDB Local files | ||||
| .dynamodb/ | ||||
							
								
								
									
										11
									
								
								setup-qemu/.prettierrc.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								setup-qemu/.prettierrc.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| { | ||||
|   "printWidth": 120, | ||||
|   "tabWidth": 2, | ||||
|   "useTabs": false, | ||||
|   "semi": true, | ||||
|   "singleQuote": true, | ||||
|   "trailingComma": "none", | ||||
|   "bracketSpacing": false, | ||||
|   "arrowParens": "avoid", | ||||
|   "parser": "typescript" | ||||
| } | ||||
							
								
								
									
										64
									
								
								setup-qemu/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								setup-qemu/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,64 @@ | ||||
| ## About | ||||
| 
 | ||||
| GitHub Action to install [QEMU static binaries](https://github.com/multiarch/qemu-user-static). | ||||
| 
 | ||||
| ___ | ||||
| 
 | ||||
| * [Usage](#usage) | ||||
| * [Customizing](#customizing) | ||||
|   * [inputs](#inputs) | ||||
| * [Limitation](#limitation) | ||||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| ```yaml | ||||
| name: ci | ||||
| 
 | ||||
| on: | ||||
|   pull_request: | ||||
|     branches: master | ||||
|   push: | ||||
|     branches: master | ||||
|     tags: | ||||
| 
 | ||||
| jobs: | ||||
|   qemu: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         id: qemu | ||||
|         uses: docker/actions/setup-qemu@v1 | ||||
|         with: | ||||
|           image: tonistiigi/binfmt:latest | ||||
|           platforms: all | ||||
|       - | ||||
|         name: Available platforms | ||||
|         run: echo ${{ steps.qemu.outputs.platforms }} | ||||
| ``` | ||||
| 
 | ||||
| ## Customizing | ||||
| 
 | ||||
| ### inputs | ||||
| 
 | ||||
| Following inputs can be used as `step.with` keys | ||||
| 
 | ||||
| | Name             | Type    | Default                     | Description                        | | ||||
| |------------------|---------|-----------------------------|------------------------------------| | ||||
| | `image`          | String  | `tonistiigi/binfmt:latest`  | QEMU static binaries Docker image. e.g. [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags) | | ||||
| | `platforms`      | String  | `all`                       | Platforms to install. e.g. `arm64,riscv64,arm` | | ||||
| 
 | ||||
| ### outputs | ||||
| 
 | ||||
| Following outputs are available | ||||
| 
 | ||||
| | Name          | Type    | Description                           | | ||||
| |---------------|---------|---------------------------------------| | ||||
| | `platforms`   | String  | Available platforms (comma separated) | | ||||
| 
 | ||||
| ## 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). | ||||
							
								
								
									
										25
									
								
								setup-qemu/action.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								setup-qemu/action.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
| # https://help.github.com/en/articles/metadata-syntax-for-github-actions | ||||
| name: 'Docker - Setup QEMU' | ||||
| description: 'GitHub Action to install QEMU static binaries' | ||||
| author: 'crazy-max' | ||||
| branding: | ||||
|   color: 'blue' | ||||
|   icon: 'truck' | ||||
| 
 | ||||
| inputs: | ||||
|   image: | ||||
|     description: 'QEMU static binaries Docker image. e.g. tonistiigi/binfmt:latest' | ||||
|     default: 'tonistiigi/binfmt:latest' | ||||
|     required: false | ||||
|   platforms: | ||||
|     description: 'Platforms to install. e.g. arm64,riscv64,arm' | ||||
|     default: 'all' | ||||
|     required: false | ||||
| 
 | ||||
| outputs: | ||||
|   platforms: | ||||
|     description: 'Available platforms (comma separated)' | ||||
| 
 | ||||
| runs: | ||||
|   using: 'node12' | ||||
|   main: 'dist/index.js' | ||||
							
								
								
									
										1716
									
								
								setup-qemu/dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1716
									
								
								setup-qemu/dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										12
									
								
								setup-qemu/jest.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								setup-qemu/jest.config.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| module.exports = { | ||||
|   clearMocks: true, | ||||
|   moduleFileExtensions: ['js', 'ts'], | ||||
|   setupFiles: ["dotenv/config"], | ||||
|   testEnvironment: 'node', | ||||
|   testMatch: ['**/*.test.ts'], | ||||
|   testRunner: 'jest-circus/runner', | ||||
|   transform: { | ||||
|     '^.+\\.ts$': 'ts-jest' | ||||
|   }, | ||||
|   verbose: false | ||||
| } | ||||
							
								
								
									
										41
									
								
								setup-qemu/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								setup-qemu/package.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | ||||
| { | ||||
|   "name": "docker-setup-qemu", | ||||
|   "description": "GitHub Action to install QEMU static binaries", | ||||
|   "main": "lib/main.js", | ||||
|   "scripts": { | ||||
|     "build": "tsc && ncc build", | ||||
|     "format": "prettier --write **/*.ts", | ||||
|     "format-check": "prettier --check **/*.ts", | ||||
|     "test": "jest --coverage", | ||||
|     "pre-checkin": "yarn run format && yarn run build" | ||||
|   }, | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "git+https://github.com/docker/actions.git", | ||||
|     "directory": "setup-qemu" | ||||
|   }, | ||||
|   "keywords": [ | ||||
|     "actions", | ||||
|     "docker", | ||||
|     "qemu" | ||||
|   ], | ||||
|   "author": "CrazyMax", | ||||
|   "license": "Apache-2.0", | ||||
|   "dependencies": { | ||||
|     "@actions/core": "^1.2.4", | ||||
|     "@actions/exec": "^1.0.4" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/jest": "^26.0.3", | ||||
|     "@types/node": "^14.0.14", | ||||
|     "@zeit/ncc": "^0.22.3", | ||||
|     "dotenv": "^8.2.0", | ||||
|     "jest": "^26.1.0", | ||||
|     "jest-circus": "^26.1.0", | ||||
|     "jest-runtime": "^26.1.0", | ||||
|     "prettier": "^2.0.5", | ||||
|     "ts-jest": "^26.1.1", | ||||
|     "typescript": "^3.9.5", | ||||
|     "typescript-formatter": "^7.2.2" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										34
									
								
								setup-qemu/src/exec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								setup-qemu/src/exec.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | ||||
| import * as actionsExec from '@actions/exec'; | ||||
| import {ExecOptions} from '@actions/exec'; | ||||
| 
 | ||||
| export interface ExecResult { | ||||
|   success: boolean; | ||||
|   stdout: string; | ||||
|   stderr: string; | ||||
| } | ||||
| 
 | ||||
| export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => { | ||||
|   let stdout: string = ''; | ||||
|   let stderr: string = ''; | ||||
| 
 | ||||
|   const options: ExecOptions = { | ||||
|     silent: silent, | ||||
|     ignoreReturnCode: true | ||||
|   }; | ||||
|   options.listeners = { | ||||
|     stdout: (data: Buffer) => { | ||||
|       stdout += data.toString(); | ||||
|     }, | ||||
|     stderr: (data: Buffer) => { | ||||
|       stderr += data.toString(); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   const returnCode: number = await actionsExec.exec(command, args, options); | ||||
| 
 | ||||
|   return { | ||||
|     success: returnCode === 0, | ||||
|     stdout: stdout.trim(), | ||||
|     stderr: stderr.trim() | ||||
|   }; | ||||
| }; | ||||
							
								
								
									
										37
									
								
								setup-qemu/src/main.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								setup-qemu/src/main.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| import * as os from 'os'; | ||||
| import * as core from '@actions/core'; | ||||
| import * as exec from './exec'; | ||||
| 
 | ||||
| interface Platforms { | ||||
|   supported: string[]; | ||||
|   available: string[]; | ||||
| } | ||||
| 
 | ||||
| async function run(): Promise<void> { | ||||
|   try { | ||||
|     if (os.platform() !== 'linux') { | ||||
|       core.setFailed('Only supported on linux platform'); | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     const image: string = core.getInput('image') || 'tonistiigi/binfmt:latest'; | ||||
|     const platforms: string = core.getInput('platforms') || 'all'; | ||||
| 
 | ||||
|     core.info(`💎 Installing QEMU static binaries...`); | ||||
|     await exec.exec('docker', ['run', '--rm', '--privileged', image, '--install', platforms], false); | ||||
| 
 | ||||
|     core.info('🛒 Extracting available platforms...'); | ||||
|     await exec.exec(`docker`, ['run', '--rm', '--privileged', image], true).then(res => { | ||||
|       if (res.stderr != '' && !res.success) { | ||||
|         throw new Error(res.stderr); | ||||
|       } | ||||
|       const platforms: Platforms = JSON.parse(res.stdout.trim()); | ||||
|       core.info(`${platforms.supported.join(',')}`); | ||||
|       core.setOutput('platforms', platforms.supported.join(',')); | ||||
|     }); | ||||
|   } catch (error) { | ||||
|     core.setFailed(error.message); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| run(); | ||||
							
								
								
									
										18
									
								
								setup-qemu/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								setup-qemu/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| { | ||||
|   "compilerOptions": { | ||||
|     "target": "es6", | ||||
|     "module": "commonjs", | ||||
|     "lib": [ | ||||
|       "es6", | ||||
|       "dom" | ||||
|     ], | ||||
|     "newLine": "lf", | ||||
|     "outDir": "./lib", | ||||
|     "rootDir": "./src", | ||||
|     "strict": true, | ||||
|     "noImplicitAny": false, | ||||
|     "esModuleInterop": true, | ||||
|     "sourceMap": true | ||||
|   }, | ||||
|   "exclude": ["node_modules", "**/*.test.ts"] | ||||
| } | ||||
							
								
								
									
										3755
									
								
								setup-qemu/yarn.lock
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3755
									
								
								setup-qemu/yarn.lock
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user