[Team-B1ND/dodamdodam-myinfo-web] Merge pull request #40 from Team-B1ND/hotfix/#39[Hotfix] 프로필 수정 오류 해결 (#39) #150
This file contains 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: Deploy Web Project | |
run-name: '[${{ github.event.client_payload.repo_name }}] ${{ github.event.client_payload.title }}' | |
on: | |
repository_dispatch: | |
types: [trigger-deploy] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code Repository | |
uses: actions/checkout@v2 | |
with: | |
repository: ${{ github.event.client_payload.repo_name }} | |
ref: ${{ github.event.client_payload.branch }} | |
- name: Set Environment Variables | |
id: set-env | |
run: | | |
echo "SOURCE_DIRECTORY=${{ github.event.client_payload.source_directory }}" >> $GITHUB_ENV | |
echo "DESTINATION_DIRECTORY=${{ github.event.client_payload.destination_directory }}" >> $GITHUB_ENV | |
echo "PROJECT_NAME=${{ github.event.client_payload.project_name }}" >> $GITHUB_ENV | |
echo "PACKAGE_MANAGER_CONFIG_COMMAND=${{ github.event.client_payload.package_manager_config_command }}" >> $GITHUB_ENV | |
echo "PACKAGE_MANAGER=${{ github.event.client_payload.package_manager }}" >> $GITHUB_ENV | |
- name: Ensure Config Directory Exists | |
run: mkdir -p ./src/config | |
- name: Set Config Json File | |
id: create-json | |
uses: jsdaniell/create-json@v1.2.2 | |
with: | |
name: 'config.json' | |
json: ${{ github.event.client_payload.config_secret }} | |
dir: './src/config' | |
- name: Install Dependencies | |
run: | | |
${{ env.PACKAGE_MANAGER_CONFIG_COMMAND }} | |
${{ env.PACKAGE_MANAGER }} install | |
- name: Build Project | |
run: | | |
${{ env.PACKAGE_MANAGER }} run build | |
- name: Add SSH key | |
uses: webfactory/ssh-agent@v0.5.3 | |
with: | |
ssh-private-key: ${{ secrets.SERVER_SSH_KEY }} | |
- name: Create Destination Directory If Not Exists | |
run: | | |
ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} \ | |
"sudo mkdir -p ${{ secrets.DOCKER_VOLUMES_PATH }}/${{ env.PROJECT_NAME }}/_data/${{ env.DESTINATION_DIRECTORY }}" | |
- name: Deploy Files to Server | |
run: | | |
rsync -avz -e "ssh -o StrictHostKeyChecking=no" \ | |
--rsync-path="sudo rsync" \ | |
./${{ env.SOURCE_DIRECTORY }}/ \ | |
${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:${{ secrets.DOCKER_VOLUMES_PATH }}/${{ env.PROJECT_NAME }}/_data/${{ env.DESTINATION_DIRECTORY }} | |
- name: Nginx Reload | |
run: | | |
ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} \ | |
"docker compose -f /home/${{ secrets.EC2_USER }}/docker/infrastructure-docker-compose.yml restart nginx" |