Skip to content

Commit

Permalink
Add ability to run Docker workflow without pushing
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Apr 7, 2022
1 parent 9e14d07 commit 1695055
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ name: docker-build-and-push

on:
workflow_dispatch:
pull_request_target:
types:
- labeled
inputs:
push_to_docker_hub:
description: Push to Docker Hub
type: boolean
required: true
default: false

jobs:
docker:
if: contains(github.event.pull_request.labels.*.name, 'docker-push') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -30,7 +32,8 @@ jobs:
tags: sqren/backport:dev
- name: Test image before push
run: docker run --rm -v $(pwd):/app:ro -v ~/.backport:/root/.backport sqren/backport:dev -v
- name: Build and push
- name: Push to Docker Hub
if: github.event.inputs.push_to_docker_hub == 'true'
uses: docker/build-push-action@v2
with:
context: ./docker
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"postinstall": "test -f ./dist/scripts/runPostinstall.js && node ./dist/scripts/runPostinstall.js || echo 'Dist folder missing'",
"version": "echo \"Bumping version\" && yarn extractPackageVersion && git add src/utils/packageVersion.ts && yarn tsc",
"prepare": "husky install",
"prepublishOnly": "yarn lint && yarn tsc",
"prepublishOnly": "rm -rf ./dist/ && yarn lint && yarn tsc",
"extractPackageVersion": "node -p \"'export const PACKAGE_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" | prettier --parser typescript > src/utils/packageVersion.ts",
"lint-and-test": "yarn tsc && yarn lint && yarn test-all",
"lint": "echo \"Running lint\" && eslint './**/*.{ts,js}'",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/child-process-promisified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export async function spawnPromise(
stderr: string;
stdout: string;
}> {
const fullCmd = `${cmd} ${cmdArgs.join(' ')}`;
logger.info(`Running command: "${fullCmd}"`);

return new Promise(function (resolve, reject) {
const subprocess = childProcess.spawn(cmd, cmdArgs, { cwd });
let stderr = '';
Expand All @@ -39,9 +42,6 @@ export async function spawnPromise(
});

subprocess.on('close', (code) => {
const fullCmd = `${cmd} ${cmdArgs.join(' ')}`;
logger.info(`Running command: "${fullCmd}"`);

if (code === 0 || code === null) {
resolve({ cmdArgs, code, stderr, stdout });
} else {
Expand Down

0 comments on commit 1695055

Please sign in to comment.