-
Notifications
You must be signed in to change notification settings - Fork 4
60 lines (53 loc) · 2.56 KB
/
changed-packages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Turbo dry run to determine which apps have changed between the latest commit and target or previous commit
# For PR:s this comparison is done against the main branch
name: 'Determine changed packages'
on:
workflow_call:
outputs:
changed_packages:
description: 'Stringified JSON array of changed packages in this changeset'
value: ${{ jobs.dry-run.outputs.changed_packages }}
admin_changed:
description: 'Indicates if the Admin UI or its dependencies have changed'
value: ${{ jobs.dry-run.outputs.admin_changed }}
ui_changed:
description: 'Indicates if the UI or its dependencies have changed'
value: ${{ jobs.dry-run.outputs.ui_changed }}
jobs:
dry-run:
runs-on: ubuntu-latest
env:
# TODO why is this named so? why isn't it just GIT_HASH?
TURBO_REF_FILTER: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
outputs:
changed_packages: ${{ steps.output-changed-packages.outputs.changed_packages }}
admin_changed: ${{ steps.admin-changed.outputs.result }}
ui_changed: ${{ steps.ui-changed.outputs.result }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Changeset
id: changeset
run: |
echo 'Generating a changeset for ' $TURBO_REF_FILTER
echo 'result<<CHANGESET_DELIMITER' >> $GITHUB_OUTPUT
# TODO why is there a global-deps flag? removing it didn't fix the issue
# FIXME this part is probably broken (the next step fails on CI)
echo "$(npx -y turbo build --dry-run=json --filter=...[$TURBO_REF_FILTER] --global-deps=.github/*)" >> $GITHUB_OUTPUT
echo 'CHANGESET_DELIMITER' >> $GITHUB_OUTPUT
- name: Output changed packages
id: output-changed-packages
run: |
echo 'Saving the changeset for ' $TURBO_REF_FILTER
echo 'changed_packages<<CHANGED_PACKAGES_DELIMITER' >> $GITHUB_OUTPUT
echo "${{ toJSON(fromJSON(steps.changeset.outputs.result).packages) }}" >> $GITHUB_OUTPUT
echo 'CHANGED_PACKAGES_DELIMITER' >> $GITHUB_OUTPUT
- name: Did the Admin UI or its dependencies change?
id: admin-changed
if: ${{ contains(fromJSON(steps.changeset.outputs.result).packages, 'admin-ui') }}
run: echo "result=true" >> $GITHUB_OUTPUT
- name: Did the UI or its dependencies change?
id: ui-changed
if: ${{ contains(fromJSON(steps.changeset.outputs.result).packages, 'ui') }}
run: echo "result=true" >> $GITHUB_OUTPUT