Skip to content

Commit

Permalink
Fix on scripts and runner
Browse files Browse the repository at this point in the history
  • Loading branch information
ilteoood committed Jan 6, 2020
1 parent 6e98909 commit cc1e8fe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
16 changes: 13 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ const child_process = require('child_process');
async function docker_buildx() {
try {
checkPlatform();
cloneMyself();
const imageName = extractInput('imageName', true);
await executeShellScript('install_buildx');
const imageTag = extractInput('tag', false, 'latest');
const publish = core.getInput('publish');
const platform = extractInput('platform', false, 'linux/amd64,linux/arm64,linux/arm/v7');
const buildFunction = publish ? buildAndPublish : buildOnly;
buildFunction(platform, imageName, imageTag);
await buildFunction(platform, imageName, imageTag);
cleanMyself();
} catch (error) {
core.setFailed(error.message);
}
Expand All @@ -37,9 +39,9 @@ function checkRequiredInput(inputName, inputValue) {

async function executeShellScript(scriptName, ...parameters) {
parameters = (parameters || []).join(' ');
command = `./scripts/${scriptName}.sh ${parameters}`;
command = `sudo docker_buildx/scripts/${scriptName}.sh ${parameters}`;
console.log(`Executing: ${command}`);
output = child_process.execSync(`./scripts/${scriptName}.sh ${parameters}`);
output = child_process.execSync(command);
console.log(`Output: ${output}`);
}

Expand All @@ -54,4 +56,12 @@ async function buildOnly(platform, imageName, imageTag) {
await executeShellScript('docker_build', platform, imageName, imageTag);
}

function cloneMyself() {
child_process.execSync(`git clone https://github.com/ilteoood/docker_buildx`);
}

function cleanMyself() {
child_process.execSync(`rm -rf docker_buildx`);
}

docker_buildx();
1 change: 1 addition & 0 deletions scripts/docker_build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh -l
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx build --platform $1 -t $2:$3 .
1 change: 1 addition & 0 deletions scripts/docker_build_push.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh -l
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx build --platform $1 --push -t $2:$3 .
4 changes: 0 additions & 4 deletions scripts/install_buildx.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/bin/sh -l

# Install curl
apt-get update
apt-get install curl wget -y

# Download buildx
curl -s https://api.github.com/repos/docker/buildx/releases/latest \
| grep "browser_download_url.*buildx-*.*linux-amd64" \
Expand Down

0 comments on commit cc1e8fe

Please sign in to comment.