Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/actions/install-private-config/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Install Private Config
description: Fetch Config.xcconfig and GoogleService-Info.plist from a private repository.

inputs:
git_url:
description: Private repository git URL
required: true
git_basic_authorization:
description: Base64-encoded basic authorization header value
required: true
ref:
description: Git ref to fetch from the private repository
required: false
default: iOS

runs:
using: composite
steps:
- name: Install private config files
shell: bash
env:
PRIVATE_CONFIG_GIT_URL: ${{ inputs.git_url }}
PRIVATE_CONFIG_GIT_BASIC_AUTHORIZATION: ${{ inputs.git_basic_authorization }}
PRIVATE_CONFIG_REF: ${{ inputs.ref }}
run: |
set -euo pipefail

privateConfigCheckoutPath="$RUNNER_TEMP/private-config"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

스크립트가 중간에 실패할 경우 임시 디렉터리가 정리되지 않고 남을 수 있습니다. trap을 사용하여 스크립트가 어떤 이유로든 종료될 때 항상 임시 디렉터리가 삭제되도록 하는 것이 더 안전하고 견고합니다.

        privateConfigCheckoutPath="$RUNNER_TEMP/private-config"
        trap 'rm -rf "$privateConfigCheckoutPath"' EXIT

configSourcePath="$privateConfigCheckoutPath/resources/DevLog/Config.xcconfig"
googleServiceInfoSourcePath="$privateConfigCheckoutPath/resources/DevLog/GoogleService-Info.plist"
configDestinationPath="$GITHUB_WORKSPACE/DevLog/Resource/Config.xcconfig"
googleServiceInfoDestinationPath="$GITHUB_WORKSPACE/DevLog/Resource/GoogleService-Info.plist"

rm -rf "$privateConfigCheckoutPath"
mkdir -p "$privateConfigCheckoutPath"

git init "$privateConfigCheckoutPath"
git -C "$privateConfigCheckoutPath" remote add origin "$PRIVATE_CONFIG_GIT_URL"
git -C "$privateConfigCheckoutPath" config core.sparseCheckout true
printf '%s\n' \
'resources/DevLog/Config.xcconfig' \
'resources/DevLog/GoogleService-Info.plist' \
> "$privateConfigCheckoutPath/.git/info/sparse-checkout"

git -C "$privateConfigCheckoutPath" \
-c http.extraheader="Authorization: Basic $PRIVATE_CONFIG_GIT_BASIC_AUTHORIZATION" \
fetch --depth 1 origin "$PRIVATE_CONFIG_REF"
git -C "$privateConfigCheckoutPath" checkout FETCH_HEAD

if [ ! -f "$configSourcePath" ]; then
echo "Missing private config file at $configSourcePath" >&2
exit 1
fi

if [ ! -f "$googleServiceInfoSourcePath" ]; then
echo "Missing private GoogleService-Info.plist at $googleServiceInfoSourcePath" >&2
exit 1
fi

install -m 600 "$configSourcePath" "$configDestinationPath"
install -m 600 "$googleServiceInfoSourcePath" "$googleServiceInfoDestinationPath"

- name: Clean private config checkout
shell: bash
run: rm -rf "$RUNNER_TEMP/private-config"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이전 스텝에서 trap을 사용하여 임시 파일 정리를 하도록 수정하면 이 스텝은 더 이상 필요하지 않습니다. Install private config files 스텝이 실패할 경우 이 스텝은 실행되지 않으므로, trap을 사용하는 것이 더 견고한 방법입니다. 이 스텝은 제거하는 것을 권장합니다.

8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
env:
SCHEME: DevLog
XCODE_VERSION: latest
MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}

permissions:
contents: read
Expand Down Expand Up @@ -49,6 +51,12 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install private config files
uses: ./.github/actions/install-private-config
with:
git_url: ${{ env.MATCH_GIT_URL }}
git_basic_authorization: ${{ env.MATCH_GIT_BASIC_AUTHORIZATION }}

- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ jobs:
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}

- name: Install private config files
uses: ./.github/actions/install-private-config
with:
git_url: ${{ env.MATCH_GIT_URL }}
git_basic_authorization: ${{ env.MATCH_GIT_BASIC_AUTHORIZATION }}

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/testflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install private config files
uses: ./.github/actions/install-private-config
with:
git_url: ${{ env.MATCH_GIT_URL }}
git_basic_authorization: ${{ env.MATCH_GIT_BASIC_AUTHORIZATION }}

- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
Expand Down Expand Up @@ -61,6 +67,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install private config files
uses: ./.github/actions/install-private-config
with:
git_url: ${{ env.MATCH_GIT_URL }}
git_basic_authorization: ${{ env.MATCH_GIT_BASIC_AUTHORIZATION }}

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ node_modules/
lib/

# Gem
.bundle/
vendor/bundle/

# Fastlane
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ platform :ios do

lane :upload_testflight_build do
api_key = asc_api_key
ipa_output_path = File.expand_path(TESTFLIGHT_IPA_OUTPUT_PATH, Dir.pwd)
ipa_output_path = lane_context[SharedValues::IPA_OUTPUT_PATH].to_s

UI.user_error!("Missing built ipa at #{ipa_output_path}") if !File.exist?(ipa_output_path)

Expand Down
Loading