Skip to content

Commit 98f3c6d

Browse files
committed
Add an additional job to determine how the workflow is called
1 parent e51d665 commit 98f3c6d

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

.github/workflows/reusable_build_all_apps.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,44 @@ on:
88
default: ''
99
type: string
1010
workflow_dispatch:
11-
inputs:
12-
c_sdk_branch:
13-
type: string
14-
required: false
15-
default: ''
1611
pull_request:
1712

1813
env:
1914
C_SDK_URL: 'https://github.com/LedgerHQ/ledger-secure-sdk.git'
15+
RUST_SDK_URL: 'https://github.com/LedgerHQ/ledger-device-rust-sdk.git'
2016

2117
jobs:
18+
how-workflow-is-called:
19+
name: Determine how the workflow is called
20+
runs-on: ubuntu-latest
21+
outputs:
22+
repository: ${{ steps.get_repo_and_branch.outputs.repo }}
23+
branch: ${{ steps.get_repo_and_branch.outputs.branch }}
24+
steps:
25+
- name: Get repository and branch
26+
id: get_repo_and_branch
27+
run: |
28+
if [ -n "${{ github.event.inputs.c_sdk_branch }}" ]; then
29+
echo "repo=$RUST_SDK_URL" >> $GITHUB_OUTPUT
30+
echo "branch='refs/heads/master'" >> $GITHUB_OUTPUT
31+
else
32+
echo "repo=${{ github.repository}}" >> $GITHUB_OUTPUT
33+
echo "branch=${{ github.ref }}" >> $GITHUB_OUTPUT
34+
fi
2235
retrieve-rust-apps:
2336
name: Retrieve Rust Apps
2437
runs-on: ubuntu-latest
38+
needs: how-workflow-is-called
2539
outputs:
2640
rust_apps: ${{ steps.get_rust_apps.outputs.rust_apps }}
2741
exclude_apps: ${{ steps.get_rust_apps.outputs.exclude_apps }}
2842
ledger_devices: ${{ steps.get_rust_apps.outputs.ledger_devices }}
2943
steps:
30-
- name: Display context
31-
run: |
32-
echo "github.repository: ${{ github.repository }}"
33-
echo "github.ref: ${{ github.ref }}"
34-
echo "github.event_name: ${{ github.event_name }}"
35-
echo "github.head_ref: ${{ github.head_ref }}"
36-
echo "github.event.inputs.c_sdk_branch: ${{ github.event.inputs.c_sdk_branch }}"
3744
- name: Checkout repository
3845
uses: actions/checkout@v4
3946
with:
40-
repository: ${{ github.repository }}
41-
ref: ${{ github.event_name == 'workflow_call' && 'refs/heads/master' || github.ref }}
47+
repository: ${{ needs.how-workflow-is-called.outputs.repository }}
48+
ref: ${{ needs.how-workflow-is-called.outputs.branch }}
4249
- name: Set up Python
4350
uses: actions/setup-python@v4
4451
with:
@@ -66,7 +73,7 @@ jobs:
6673
6774
test-build:
6875
name: Build for all targets
69-
needs: retrieve-rust-apps
76+
needs: [retrieve-rust-apps, how-workflow-is-called]
7077
strategy:
7178
fail-fast: false
7279
matrix:
@@ -83,8 +90,8 @@ jobs:
8390
uses: actions/checkout@v4
8491
with:
8592
path: sdk
86-
repository: ${{ github.repository }}
87-
ref: ${{ github.event_name == 'workflow_call' && 'refs/heads/master' || github.ref }}
93+
repository: ${{ needs.how-workflow-is-called.outputs.repository }}
94+
ref: ${{ needs.how-workflow-is-called.outputs.branch }}
8895
- name: Clone App
8996
uses: actions/checkout@v4
9097
with:

0 commit comments

Comments
 (0)