From 29edef4a04b9c9fa18195dad0016c30d3766e2d4 Mon Sep 17 00:00:00 2001 From: Gustav Eikaas Date: Thu, 10 Aug 2023 08:29:28 +0200 Subject: [PATCH] ci: try remove unnecessary actions --- .github/workflows/test.yml | 20 +------------------- action.yml | 2 +- github-action/script/main.js | 29 +++++++++++++++++++++++++++++ github-action/tsconfig.json | 2 +- 4 files changed, 32 insertions(+), 21 deletions(-) create mode 100644 github-action/script/main.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c50a7522..8d0545146 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,19 +3,7 @@ on: # rebuild any PRs and main branch changes push: jobs: - build: # make sure build/ci work properly - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Dependencies - run: npx pnpm i - - - name: Build Code - run: npx pnpm build - - test: # make sure the action works on a clean machine without building + changed: # make sure the action works on a clean machine without building runs-on: ubuntu-latest steps: - name: Checkout @@ -23,12 +11,6 @@ jobs: with: fetch-depth: 0 # Required to fetch range - - name: Install Dependencies - run: npx pnpm i - - - name: Build Code - run: npx pnpm build - # Run the action on the yarn-workspaces example - name: Test Action id: changedAction diff --git a/action.yml b/action.yml index 33645ede1..59e0907e2 100644 --- a/action.yml +++ b/action.yml @@ -11,4 +11,4 @@ outputs: runs: using: 'node16' - main: 'github-action/dist/main.js' + main: 'github-action/script/main.js' diff --git a/github-action/script/main.js b/github-action/script/main.js new file mode 100644 index 000000000..64ed59239 --- /dev/null +++ b/github-action/script/main.js @@ -0,0 +1,29 @@ +import { execSync } from 'child_process'; +import { join } from 'path'; +import { getInput, debug, setFailed, setOutput, setCommandEcho } from '@actions/core'; +const run = async () => { + try { + setCommandEcho(true); + const turboCommand = getInput('turbo-command', { required: true }); + const workingDirectory = getInput('working-directory', { required: false }) ?? './'; + const cwd = join(process.cwd(), workingDirectory); + debug(`Running command: ${turboCommand} in directory ${workingDirectory}`); + const json = execSync(`npx turbo run ${turboCommand} --dry-run=json`, { + cwd: cwd, + encoding: 'utf-8', + }); + debug(`Output from Turborepo: ${json}`); + const parsedOutput = JSON.parse(json); + const changed = !!parsedOutput.packages.length; + setOutput('changed', changed); + } + catch (error) { + if (error instanceof Error || typeof error === 'string') { + setFailed(error); + } + else { + setFailed('Unknown error occured.'); + } + } +}; +void run(); diff --git a/github-action/tsconfig.json b/github-action/tsconfig.json index c1359dda5..d888adf7a 100644 --- a/github-action/tsconfig.json +++ b/github-action/tsconfig.json @@ -11,7 +11,7 @@ "lib": ["ES2022", "dom"], "skipLibCheck": true, "skipDefaultLibCheck": true, - "outDir": "dist" + "outDir": "script" }, "exclude": ["node_modules"] }