|
56 | 56 | sentry-dsn: |
57 | 57 | description: 'Sentry DSN for error reporting' |
58 | 58 | required: false |
| 59 | + git-token: |
| 60 | + description: 'Token (PAT or App token) with read access to private git dependencies / submodules. When set, the compile job configures git credentials so private cross-repo submodules and cargo git dependencies can be fetched. Leave unset for fully public projects.' |
| 61 | + required: false |
59 | 62 |
|
60 | 63 | defaults: |
61 | 64 | run: |
@@ -122,9 +125,27 @@ jobs: |
122 | 125 | - name: Checkout code |
123 | 126 | uses: actions/checkout@v6 |
124 | 127 | with: |
125 | | - submodules: true |
| 128 | + # When a git-token is provided, submodules are initialised manually in |
| 129 | + # the next step (after credentials are configured) so that private |
| 130 | + # cross-repo submodules can be cloned. Otherwise behave as before. |
| 131 | + submodules: ${{ secrets.git-token != '' && 'false' || 'true' }} |
126 | 132 | fetch-depth: 1 |
127 | 133 |
|
| 134 | + - name: Configure private git credentials |
| 135 | + if: ${{ secrets.git-token != '' }} |
| 136 | + env: |
| 137 | + GIT_TOKEN: ${{ secrets.git-token }} |
| 138 | + run: | |
| 139 | + # Authenticate all github.com access with the provided token so that |
| 140 | + # private cross-repo submodules and cargo git dependencies resolve. |
| 141 | + git config --global url."https://x-access-token:${GIT_TOKEN}@github.com/".insteadOf "https://github.com/" |
| 142 | + # Make cargo use the git CLI (which honours the credential above) when |
| 143 | + # fetching git dependencies. |
| 144 | + echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" >> "$GITHUB_ENV" |
| 145 | + # Now that credentials are set, initialise submodules. |
| 146 | + git submodule sync --recursive |
| 147 | + git submodule update --init --recursive |
| 148 | +
|
128 | 149 | # ── Sccache: restore/auto-save disk cache + local disk setup ── |
129 | 150 | - name: Determine sccache directory |
130 | 151 | if: inputs.enable-sccache |
|
0 commit comments