Pull Config #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pull Config | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment_name: | |
| description: '가져올 설정 브랜치' | |
| required: true | |
| type: choice | |
| options: | |
| - prod | |
| - develop | |
| jobs: | |
| sync-config: | |
| runs-on: [self-hosted] | |
| environment: ${{ inputs.environment_name }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: '환경 변수를 검증합니다.' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| test -n "${{ vars.CONFIG_DIR }}" | |
| if [ "${{ vars.CONFIG_DIR }}" = "/" ]; then | |
| echo "CONFIG_DIR must not be /" | |
| exit 1 | |
| fi | |
| - name: '설정 저장소를 내려 받습니다.' | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: Queuing-org/backend-config | |
| token: ${{ secrets.CONFIG_REPO_TOKEN }} | |
| ref: ${{ vars.CONFIG_REF }} | |
| path: .tmp-config | |
| - name: '서버 설정 디렉터리에 파일을 복사합니다.' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| BASE_DIR="${{ vars.CONFIG_DIR }}" | |
| CONFIG_REF="${{ vars.CONFIG_REF }}" | |
| TARGET_DIR="${BASE_DIR}/${CONFIG_REF}" | |
| mkdir -p "${TARGET_DIR}" | |
| if command -v rsync >/dev/null 2>&1; then | |
| rsync -a --delete .tmp-config/ "${TARGET_DIR}/" | |
| else | |
| find "${TARGET_DIR}" -mindepth 1 -maxdepth 1 -exec rm -rf {} + | |
| cp -a .tmp-config/. "${TARGET_DIR}/" | |
| fi | |
| - name: '임시 디렉터리를 정리합니다.' | |
| if: always() | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| rm -rf .tmp-config |