Skip to content

Commit d5b49c4

Browse files
authored
fix(ci): build matrix value dynamically based on optional dispatch input (#7234)
* fix(ci): build matrix value dynamically based on optional dispatch input * fix: check against env in if
1 parent 5cb9069 commit d5b49c4

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

.github/workflows/update-dependencies.yaml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,31 @@ permissions:
2222
contents: none # We use the github app token to push the changes
2323

2424
jobs:
25+
configure_matrix:
26+
name: Configure matrix
27+
runs-on: ubuntu-latest
28+
outputs:
29+
group_name: ${{ steps.define_groups.outputs.group_name }}
30+
steps:
31+
- id: define_groups
32+
name: Define groups to update
33+
env:
34+
SHOULD_INCLUDE_ALL_GROUPS: ${{ inputs.group_name == '' || inputs.group_name == 'all' }}
35+
run: |
36+
echo "Configuring matrix (inputs.group_name=${{ inputs.group_name }})"
37+
if [[ "$SHOULD_INCLUDE_ALL_GROUPS" = "true" ]]; then
38+
# When adding new group, don't forget to update the `workflow_dispatch`
39+
echo 'group_name=["electron","eslint","typescript","mongosh"]' >> "$GITHUB_OUTPUT"
40+
else
41+
echo 'group_name=["${{ inputs.group_name }}"]' >> "$GITHUB_OUTPUT"
42+
fi
2543
update_dependencies_group:
2644
name: Update ${{ matrix.group_name }} to latest
2745
runs-on: ubuntu-latest
46+
needs: configure_matrix
2847
strategy:
2948
matrix:
30-
group_name:
31-
# When adding new group, don't forget to update the
32-
# `workflow_dispatch.inputs`
33-
- electron
34-
- eslint
35-
- typescript
36-
- mongosh
37-
if: ${{ inputs.group_name == '' || inputs.group_name == 'all' || inputs.group_name == matrix.group_name }}
49+
group_name: ${{ fromJSON(needs.configure_matrix.outputs.group_name) }}
3850
steps:
3951
- name: Create Github App Token
4052
uses: mongodb-js/devtools-shared/actions/setup-bot-token@main

0 commit comments

Comments
 (0)