-
Is there a preferred way to check in CI which apps have changed? In our setup we build, test, lint and build our docker image in CI and push it to AWS ECR. Anyway, I only want to build the docker images of the changed apps (or a related package). On github actions there is the if conditional. So it would be perfect if there is something like: name: example-workflow
on: [push]
jobs:
production-deploy:
if: ${{ yarn turbo changed --scope=web --include-dependencies }} Idk if this would work 😬 |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 22 replies
-
There should be a --since flag on the run command |
Beta Was this translation helpful? Give feedback.
-
Since there's already the |
Beta Was this translation helpful? Give feedback.
-
In our CI there is an explicit docker build step for each app. The Or how would you do that with |
Beta Was this translation helpful? Give feedback.
-
See #380 (https://github.com/vercel/turborepo/releases/tag/v1.1.7)
|
Beta Was this translation helpful? Give feedback.
-
@jaredpalmer do you have an example of how to use this as Ignored Build Step in Vercel? Something like
? |
Beta Was this translation helpful? Give feedback.
-
To add to this discussion I highly recommend looking into |
Beta Was this translation helpful? Give feedback.
-
Here is an example how we do this on github actions: name: Pipeline
# ... more global settings (not relevant here)
jobs:
checks:
name: Build
# ... more job settings (not relevent here)
env:
TURBO_RUN_FILTER: ${{ github.event_name == 'pull_request' && '...[origin/main]' || '...[HEAD^]' }}
outputs:
# Defining a job output for used by the next jobs:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs
changed-app: ${{ steps.changed-app.outputs.result }}
changed-docs: ${{ steps.changed-docs.outputs.result }}
steps:
# ... all basic steps you need (checkout etc.)
- name: Changeset
id: changeset
# 1. We need the 'output' of a turbo dry-run to get a json with all affected packages of these run.
# 2. The multi line json string is transformed to a single line string.
# 3. The single line json string is set to an 'output' (or result) of this step.
run: |
content=`yarn build --filter=$TURBO_RUN_FILTER --dry-run=json`
# the following lines are required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "::set-output name=result::$content"
- name: Changed app?
id: changed-app
# 1. Using the 'output' of the 'changeset' step inside the `if` to check if the specific app has changed
# 2. When `true`, we store it in the 'output' of the current step.
if: ${{ contains(fromJSON(steps.changeset.outputs.result).packages, 'app') }}
run: |
echo "::set-output name=result::true"
- name: Changed docs?
id: changed-docs
# 1. Using the 'output' of the 'changeset' step inside the `if` to check if the specific app has changed
# 2. When `true`, we store it in the 'output' of the current step.
if: ${{ contains(fromJSON(steps.changeset.outputs.result).packages, 'docs') }}
run: |
echo "::set-output name=result::true"
publish_app:
name: Publish app
needs: [checks]
# ... more job settings (not relevent here)
if: ${{ needs.checks.outputs.changed-app }}
# Now this job only runs when the 'output' of the previous step is `true` for `changed-app`
publish_docs:
name: Publish docs
needs: [checks]
# ... more job settings (not relevent here)
if: ${{ needs.checks.outputs.changed-docs }}
# Now this job only runs when the 'output' of the previous step is `true` for `changed-docs` I tried a lot to achieve this (env vars etc.). If anyone has a simpler and not so error-prone solution, I would love to see. @jaredpalmer maybe the team can check my solution? I think a custom turborepo github action would be a nice tool here. |
Beta Was this translation helpful? Give feedback.
-
We have this use case here in quite a lot of repositories and I ended up writing a Github Action just for that. Hopefully turborepo will provide an official action at some point 🤞 |
Beta Was this translation helpful? Give feedback.
-
Following up in this discussion since I'm very interested in this. Looks like you all provided solid solutions. However I was wondering since most of the solutions forces me to be explicit about what package I want to check, is there a way to make this dynamic? Like check all my package/apps and see if any has changed. Has anything been updated with turborepo that might support this out of the box? Also sorry for tailing your original discussion @bobaaaaa |
Beta Was this translation helpful? Give feedback.
-
Skipping CI task: https://turbo.build/repo/docs/core-concepts/monorepos/skipping-tasks tldr; |
Beta Was this translation helpful? Give feedback.
Here is an example how we do this on github actions: