-
Notifications
You must be signed in to change notification settings - Fork 2
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
f3d0aa8
commit 392a332
Showing
1 changed file
with
63 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: API Server Ci/Cd | ||
on: | ||
push: | ||
branches: | ||
- Ci/69 | ||
- develop | ||
paths: | ||
# - 'apps/api/**' | ||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
IMAGE_NAME: api-camon | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Log in to Ncloud Container Registry | ||
env: | ||
USERNAME: ${{ secrets.NCLOUD_ACCESS_KEY }} | ||
PASSWORD: ${{ secrets.NCLOUD_SECRET_KEY }} | ||
REGISTRY_URL: ${{ secrets.NCLOUD_REGISTRY_URL }} | ||
run: | | ||
echo "$PASSWORD" | docker login -u "$USERNAME" "$REGISTRY_URL" --password-stdin | ||
- name: Build Docker image | ||
run: | | ||
docker build -t ${{ secrets.NCLOUD_REGISTRY_URL }}/$IMAGE_NAME:latest ./apps/api | ||
- name: Push to Ncloud Container Registry | ||
run: | | ||
docker push ${{ secrets.NCLOUD_REGISTRY_URL }}/$IMAGE_NAME:latest | ||
deploy-and-run: | ||
runs-on: ubuntu-latest | ||
needs: build-and-push | ||
steps: | ||
- name: SSH and deploy | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SERVER_IP }} | ||
username: ${{ secrets.SERVER_USER }} | ||
key: ${{ secrets.SSH_SERVER_KEY }} | ||
port: 22 | ||
script: | | ||
mkdir -p api | ||
cd api | ||
docker pull ${{ secrets.NCLOUD_REGISTRY_URL }}/api-camon:latest | ||
docker stop api-camon || true | ||
docker rm api-camon || true | ||
docker run -d --name api-camon -p 3000:3000 ${{ secrets.NCLOUD_REGISTRY_URL }}/api-camon:latest | ||
- name: Check container status | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SERVER_IP }} | ||
username: ${{ secrets.SERVER_USER }} | ||
key: ${{ secrets.SSH_SERVER_KEY }} | ||
port: 22 | ||
script: | | ||
sudo docker ps -f name=api-camon |