-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b4fc9f
commit bdb379e
Showing
1 changed file
with
36 additions
and
31 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,35 +6,40 @@ on: | |
- dev | ||
|
||
jobs: | ||
build: | ||
runs-on: self-hosted | ||
defaults: | ||
run: | ||
working-directory: /var/www/aihomework/dev | ||
|
||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Pull from github | ||
id: pull | ||
run: | | ||
git stash | ||
git pull origin dev | ||
- name: install dependencies | ||
run: yarn install | ||
|
||
- name: Run Test | ||
run: yarn test | ||
|
||
- name: buld the dist | ||
run: yarn build | ||
|
||
- name: migrate | ||
run: yarn reset-db | ||
|
||
- name: setup service file | ||
run: sudo cp server-script/aihomeworkdev.service /etc/systemd/system | ||
|
||
- name: start the app | ||
run: | | ||
sudo systemctl daemon-reload | ||
sudo systemctl restart aihomeworkdev | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t backend_dev . | ||
- name: Save Docker image to tarball | ||
run: | | ||
docker save backend_dev | gzip > backend_dev.tar.gz | ||
- name: Upload to server | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
port: ${{ secrets.PORT }} | ||
source: "backend_dev.tar.gz" | ||
target: "/opt/backend-tar/" | ||
|
||
- name: Load Docker image on server and start | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
port: ${{ secrets.PORT }} | ||
script: | | ||
docker load -i /opt/backend-tar/backend_dev.tar.gz | ||
cd /var/www/aihomework/dev | ||
docker-compose down | ||
docker-compose up -d |