no commit msg #36
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: Deploy to 247 Server | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'onecard-web/**' | |
| - 'onecard-api/**' | |
| jobs: | |
| deploy: | |
| name: Deploy ${{ matrix.name }} | |
| runs-on: self-hosted | |
| strategy: | |
| matrix: | |
| include: | |
| - name: onecard-web | |
| path: onecard-web | |
| host_port: 9413 | |
| container_port: 8000 | |
| env_secret: ENV_FILE_WEB | |
| - name: onecard-api | |
| path: onecard-api | |
| host_port: 9414 | |
| container_port: 8001 | |
| env_secret: ENV_FILE_API | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| - name: Sync project files to target directory | |
| run: | | |
| rsync -av --delete --exclude '.git' \ | |
| ${{ github.workspace }}/ \ | |
| /home/ubuntu/OSS-onecard/ | |
| - name: Create .env file from secrets | |
| run: | | |
| echo "${{ secrets[matrix.env_secret] }}" > /home/ubuntu/OSS-onecard/${{ matrix.path }}/.env | |
| - name: Deploy to Remote Server | |
| run: | | |
| set -e | |
| cd /home/ubuntu/OSS-onecard/${{ matrix.path }} | |
| echo "Building Docker Image for ${{ matrix.name }}..." | |
| docker build -t ${{ matrix.name }} . | |
| echo "Removing old container if exists..." | |
| docker stop ${{ matrix.name }} || true | |
| docker rm ${{ matrix.name }} || true | |
| echo "Running new container for ${{ matrix.name }}..." | |
| docker run -d \ | |
| --name ${{ matrix.name }} \ | |
| --network bridge \ | |
| --env-file .env \ | |
| -p ${{ matrix.host_port }}:${{ matrix.container_port }} \ | |
| ${{ matrix.name }} |