diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5df7adf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,19 @@ +name: learn-github-actions +run-name: ${{ github.actor }} is learning GitHub Actions +on: + pull_request: + merge_group: +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: '18' + - name: Run CI Build + - run: npm install + - run: npm run build + env: + CI_DELAY: "10_000" + CI_FAIL: "" diff --git a/build.mjs b/build.mjs new file mode 100644 index 0000000..0a60b88 --- /dev/null +++ b/build.mjs @@ -0,0 +1,18 @@ +#!/usr/bin/env node + +const delay = Number(process.env.CI_DELAY || 3_000); +const shouldFail = Boolean(process.env.CI_FAIL || ''); + +console.log('config', {delay, shouldFail, raw: { delay: process.env.CI_DELAY, shouldFail: process.env.CI_FAIL}}); + +await new Promise((resolve, reject) => { + console.log(`Running build... for ${delay} seconds`); + setTimeout(() => { + if (shouldFail) { + return reject('failing.... booo'); + } + resolve(true); + }, delay); +}); + +console.log("Built!"); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..f1cef0c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "test-github-features", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "test-github-features", + "version": "1.0.0", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3854508 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "test-github-features", + "version": "1.0.0", + "description": "Repo to test github settings for PRs, CI, merging", + "main": "index.js", + "scripts": { + "build": "node ./build.mjs" + }, + "author": "", + "license": "ISC" +}