Skip to content

[Team-B1ND/dodamdodam-web] Origin/hotfix/#98 refresh token #155

[Team-B1ND/dodamdodam-web] Origin/hotfix/#98 refresh token

[Team-B1ND/dodamdodam-web] Origin/hotfix/#98 refresh token #155

Workflow file for this run

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"