Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicorn pipe #17094

Merged
merged 14 commits into from
Dec 2, 2024
48 changes: 48 additions & 0 deletions .github/workflows/unicorns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI/CD pipeline
on:
pull_request: {}
workflow_dispatch: {}
defaults:
run:
shell: bash
jobs:
check-unicorn:
name: Check if app is on unicorn track
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
timeout-minutes: 35

outputs:
IS_UNICORN: ${{ steps.unicorn-affected.outputs.IS_UNICORN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get cache
id: get-cache
uses: ./.github/actions/get-cache
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
enable-cache: 'node_modules,generated-files'

- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'

- name: Setup yarn
run: corepack enable

- name: Check unicorn affected
id: unicorn-affected
run: |
node scripts/ci/unicorn-utils.mjs
UNICORN=$(node scripts/ci/unicorn-utils.mjs)
if [ "$UNICORN" == 'true' ]; then
echo "unicorn is detected"
echo IS_UNICORN=true >> "$GITHUB_OUTPUT"
else
echo "No unicorn"
echo IS_UNICORN=false >> "$GITHUB_OUTPUT"
fi
16 changes: 16 additions & 0 deletions scripts/ci/unicorn-utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { execSync } from 'child_process'
import { workspaceRoot } from '@nx/devkit'

const unicornApps = ['unicorn-app']

try {
const affected = JSON.parse(
execSync(
`cd ${workspaceRoot} && yarn nx show projects --affected --base origin/main --json | jq -r`,
).toString(),
)
console.log(affected.some((item) => unicornApps.includes(item)))
} catch (e) {
console.error(e.message)
process.exit(1)
}
Loading