1+ import * as context from './context' ;
12import * as core from '@actions/core' ;
23import * as exec from '@actions/exec' ;
3- import { issueCommand } from '@actions/core/lib/command' ;
44
55interface Platforms {
66 supported : string [ ] ;
@@ -9,49 +9,47 @@ interface Platforms {
99
1010async function run ( ) : Promise < void > {
1111 try {
12- core . startGroup ( `Docker info` ) ;
13- await exec . exec ( 'docker' , [ 'version' ] ) ;
14- await exec . exec ( 'docker' , [ 'info' ] ) ;
15- core . endGroup ( ) ;
16-
17- const image : string = core . getInput ( 'image' ) || 'tonistiigi/binfmt:latest' ;
18- const platforms : string = core . getInput ( 'platforms' ) || 'all' ;
19-
20- core . startGroup ( `Pulling binfmt Docker image` ) ;
21- await exec . exec ( 'docker' , [ 'pull' , image ] ) ;
22- core . endGroup ( ) ;
23-
24- core . startGroup ( `Image info` ) ;
25- await exec . exec ( 'docker' , [ 'image' , 'inspect' , image ] ) ;
26- core . endGroup ( ) ;
27-
28- core . startGroup ( `Installing QEMU static binaries` ) ;
29- await exec . exec ( 'docker' , [ 'run' , '--rm' , '--privileged' , image , '--install' , platforms ] ) ;
30- core . endGroup ( ) ;
31-
32- core . startGroup ( `Extracting available platforms` ) ;
33- await exec
34- . getExecOutput ( 'docker' , [ 'run' , '--rm' , '--privileged' , image ] , {
35- ignoreReturnCode : true ,
36- silent : true
37- } )
38- . then ( res => {
39- if ( res . stderr . length > 0 && res . exitCode != 0 ) {
40- throw new Error ( res . stderr . trim ( ) ) ;
41- }
42- const platforms : Platforms = JSON . parse ( res . stdout . trim ( ) ) ;
43- core . info ( `${ platforms . supported . join ( ',' ) } ` ) ;
44- setOutput ( 'platforms' , platforms . supported . join ( ',' ) ) ;
12+ const input : context . Inputs = context . getInputs ( ) ;
13+
14+ await core . group ( `Docker info` , async ( ) => {
15+ await exec . exec ( 'docker' , [ 'version' ] , {
16+ failOnStdErr : false
17+ } ) ;
18+ await exec . exec ( 'docker' , [ 'info' ] , {
19+ failOnStdErr : false
4520 } ) ;
46- core . endGroup ( ) ;
21+ } ) ;
22+
23+ await core . group ( `Pulling binfmt Docker image` , async ( ) => {
24+ await exec . exec ( 'docker' , [ 'pull' , input . image ] ) ;
25+ } ) ;
26+
27+ await core . group ( `Image info` , async ( ) => {
28+ await exec . exec ( 'docker' , [ 'image' , 'inspect' , input . image ] ) ;
29+ } ) ;
30+
31+ await core . group ( `Installing QEMU static binaries` , async ( ) => {
32+ await exec . exec ( 'docker' , [ 'run' , '--rm' , '--privileged' , input . image , '--install' , input . platforms ] ) ;
33+ } ) ;
34+
35+ await core . group ( `Extracting available platforms` , async ( ) => {
36+ await exec
37+ . getExecOutput ( 'docker' , [ 'run' , '--rm' , '--privileged' , input . image ] , {
38+ ignoreReturnCode : true ,
39+ silent : true
40+ } )
41+ . then ( res => {
42+ if ( res . stderr . length > 0 && res . exitCode != 0 ) {
43+ throw new Error ( res . stderr . trim ( ) ) ;
44+ }
45+ const platforms : Platforms = JSON . parse ( res . stdout . trim ( ) ) ;
46+ core . info ( `${ platforms . supported . join ( ',' ) } ` ) ;
47+ context . setOutput ( 'platforms' , platforms . supported . join ( ',' ) ) ;
48+ } ) ;
49+ } ) ;
4750 } catch ( error ) {
4851 core . setFailed ( error . message ) ;
4952 }
5053}
5154
52- // FIXME: Temp fix https://github.com/actions/toolkit/issues/777
53- function setOutput ( name : string , value : unknown ) : void {
54- issueCommand ( 'set-output' , { name} , value ) ;
55- }
56-
5755run ( ) ;
0 commit comments