Merge pull request #124 from jakubcieslik99/dependabot/npm_and_yarn/c… #9
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: Deployment on "main" branch client folder push | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- 'client/**' | |
- '!.github/**' | |
- '!**/.gitignore' | |
- '!**/.eslintrc.json' | |
- '!**/.prettierrc.json' | |
- '!**/*.md' | |
- '!**/LICENSE' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: CI/CD | |
strategy: | |
matrix: | |
folder: ['client'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Extract repository name | |
run: echo "DIR=$(basename ${{ github.repository }})-${{ matrix.folder }}" >> $GITHUB_ENV | |
- name: Prepare secrets | |
uses: jakubcieslik99/secrets-vars-to-env-file-action@main | |
with: | |
secrets: false | |
vars: ${{ toJSON(vars) }} | |
hydrate-env: false | |
include: 'VITE_PREVIEW_PORT,VITE_API_URL' | |
append-script-envs: 'DIR' | |
- name: Transfer files | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.VPS_HOST }} | |
username: ${{ secrets.VPS_USER }} | |
key: ${{ secrets.VPS_KEY }} | |
port: 22 | |
source: 'client/*,.env,!**/node_modules,!.git,!.github,!**/.env.sample' | |
target: '/data/services/${{ env.DIR }}' | |
- name: Build and run service container | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.VPS_HOST }} | |
username: ${{ secrets.VPS_USER }} | |
key: ${{ secrets.VPS_KEY }} | |
port: 22 | |
envs: DIR | |
script: | | |
cd /data/services/$DIR/client | |
rm -f .env | |
mv ../.env .env | |
docker-compose -f docker-compose.yml -p $DIR up --build -d | |
exit |