[CI] Refactor changed files integration (#9643)
# BEFORE [run](https://github.com/twentyhq/twenty/actions/runs/12806801953)  # AFTER [run](https://github.com/twentyhq/twenty/actions/runs/12807034402)  ## Motivations: - less workflow to whitelist as blocking for PRs - less if condition per step cons: - quite verbose - need to manually sync the `ci-NAME-status-check` needs list to any other existing and should be dep jobs ## Version migration Migrated to the latest `changed-files@45` version, getting rid of the `set-output` usage warnings ## Tests runs: With mutation: - [Success flow](https://github.com/twentyhq/twenty/actions/runs/12791958651/job/35661546343) - [server-setup failure flow](https://github.com/twentyhq/twenty/actions/runs/12792225779) - [Other job failure flow](https://github.com/twentyhq/twenty/actions/runs/12792313463), one of the `inner` job failed - [Manual cancel flow](https://github.com/twentyhq/twenty/actions/runs/12792313463) `ci-server-status-check` also has the `cancelled` status - [Matrix failure](https://github.com/twentyhq/twenty/actions/runs/12806883553) Without mutation: - [Nothing to do flow](https://github.com/twentyhq/twenty/actions/runs/12792098384), skipped `inner` job but `ci-server-status-check` still succeeded ## Notes ### Linter We should setup a `yml` prettier and linter for the `.github/worfklows` folder ### Centralized `ci-NAME-status-check` logic Unfortunately I couldn't achieve to either make a `composite` action or a `reusable-workflow`, as I could not access the correct layer to run the `always` but also acessing the `needs` context
This commit is contained in:
37
.github/workflows/ci-website.yaml
vendored
37
.github/workflows/ci-website.yaml
vendored
@ -5,14 +5,21 @@ on:
|
||||
- main
|
||||
|
||||
pull_request:
|
||||
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
prerequisites:
|
||||
uses: ./.github/workflows/changed-files.yaml
|
||||
with:
|
||||
files: |
|
||||
package.json
|
||||
packages/twenty-website/**
|
||||
website-build:
|
||||
needs: prerequisites
|
||||
if: needs.prerequisites.outputs.any_changed == 'true'
|
||||
timeout-minutes: 3
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
@ -21,8 +28,8 @@ jobs:
|
||||
env:
|
||||
PGUSER_SUPERUSER: postgres
|
||||
PGPASSWORD_SUPERUSER: postgres
|
||||
ALLOW_NOSSL: "true"
|
||||
SPILO_PROVIDER: "local"
|
||||
ALLOW_NOSSL: 'true'
|
||||
SPILO_PROVIDER: 'local'
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
@ -34,31 +41,27 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Check for changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v11
|
||||
with:
|
||||
files: 'package.json, packages/twenty-website/**'
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.changed-files.outputs.changed == 'true'
|
||||
uses: ./.github/workflows/actions/yarn-install
|
||||
|
||||
- name: Server / Create DB
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
run: PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d postgres -c 'CREATE DATABASE "default";'
|
||||
|
||||
- name: Website / Run migrations
|
||||
if: steps.changed-files.outputs.changed == 'true'
|
||||
run: npx nx database:migrate twenty-website
|
||||
run: npx nx database:migrate twenty-website
|
||||
env:
|
||||
DATABASE_PG_URL: postgres://postgres:postgres@localhost:5432/default
|
||||
- name: Website / Build Website
|
||||
if: steps.changed-files.outputs.changed == 'true'
|
||||
run: npx nx build twenty-website
|
||||
env:
|
||||
DATABASE_PG_URL: postgres://postgres:postgres@localhost:5432/default
|
||||
|
||||
- name: Mark as VALID
|
||||
if: steps.changed-files.outputs.changed != 'true' # If no changes, mark as valid
|
||||
run: echo "No relevant changes detected. CI is valid."
|
||||
ci-website-status-check:
|
||||
if: always() && !cancelled()
|
||||
timeout-minutes: 1
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prerequisites, website-build]
|
||||
steps:
|
||||
- name: Fail job if any needs failed
|
||||
if: contains(needs.*.result, 'failure')
|
||||
run: exit 1
|
||||
|
||||
Reference in New Issue
Block a user