onecard-api start #32
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: 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 }} | |
| git pull origin main --rebase | |
| 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 }} |