|
| 1 | +name: Install Private Config |
| 2 | +description: Fetch Config.xcconfig and GoogleService-Info.plist from a private repository. |
| 3 | + |
| 4 | +inputs: |
| 5 | + git_url: |
| 6 | + description: Private repository git URL |
| 7 | + required: true |
| 8 | + git_basic_authorization: |
| 9 | + description: Base64-encoded basic authorization header value |
| 10 | + required: true |
| 11 | + ref: |
| 12 | + description: Git ref to fetch from the private repository |
| 13 | + required: false |
| 14 | + default: iOS |
| 15 | + |
| 16 | +runs: |
| 17 | + using: composite |
| 18 | + steps: |
| 19 | + - name: Install private config files |
| 20 | + shell: bash |
| 21 | + env: |
| 22 | + PRIVATE_CONFIG_GIT_URL: ${{ inputs.git_url }} |
| 23 | + PRIVATE_CONFIG_GIT_BASIC_AUTHORIZATION: ${{ inputs.git_basic_authorization }} |
| 24 | + PRIVATE_CONFIG_REF: ${{ inputs.ref }} |
| 25 | + run: | |
| 26 | + set -euo pipefail |
| 27 | +
|
| 28 | + privateConfigCheckoutPath="$RUNNER_TEMP/private-config" |
| 29 | + trap 'rm -rf "$privateConfigCheckoutPath"' EXIT |
| 30 | + configSourcePath="$privateConfigCheckoutPath/resources/DevLog/Config.xcconfig" |
| 31 | + googleServiceInfoSourcePath="$privateConfigCheckoutPath/resources/DevLog/GoogleService-Info.plist" |
| 32 | + configDestinationPath="$GITHUB_WORKSPACE/DevLog/Resource/Config.xcconfig" |
| 33 | + googleServiceInfoDestinationPath="$GITHUB_WORKSPACE/DevLog/Resource/GoogleService-Info.plist" |
| 34 | +
|
| 35 | + rm -rf "$privateConfigCheckoutPath" |
| 36 | + mkdir -p "$privateConfigCheckoutPath" |
| 37 | +
|
| 38 | + git init "$privateConfigCheckoutPath" |
| 39 | + git -C "$privateConfigCheckoutPath" remote add origin "$PRIVATE_CONFIG_GIT_URL" |
| 40 | + git -C "$privateConfigCheckoutPath" config core.sparseCheckout true |
| 41 | + printf '%s\n' \ |
| 42 | + 'resources/DevLog/Config.xcconfig' \ |
| 43 | + 'resources/DevLog/GoogleService-Info.plist' \ |
| 44 | + > "$privateConfigCheckoutPath/.git/info/sparse-checkout" |
| 45 | +
|
| 46 | + git -C "$privateConfigCheckoutPath" \ |
| 47 | + -c http.extraheader="Authorization: Basic $PRIVATE_CONFIG_GIT_BASIC_AUTHORIZATION" \ |
| 48 | + fetch --depth 1 origin "$PRIVATE_CONFIG_REF" |
| 49 | + git -C "$privateConfigCheckoutPath" checkout FETCH_HEAD |
| 50 | +
|
| 51 | + if [ ! -f "$configSourcePath" ]; then |
| 52 | + echo "Missing private config file at $configSourcePath" >&2 |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | +
|
| 56 | + if [ ! -f "$googleServiceInfoSourcePath" ]; then |
| 57 | + echo "Missing private GoogleService-Info.plist at $googleServiceInfoSourcePath" >&2 |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | +
|
| 61 | + install -m 600 "$configSourcePath" "$configDestinationPath" |
| 62 | + install -m 600 "$googleServiceInfoSourcePath" "$googleServiceInfoDestinationPath" |
0 commit comments