Skip to content

Commit 7ed7e26

Browse files
authored
Create deploy-api.yml
1 parent 7a30e47 commit 7ed7e26

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/deploy-api.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Deploy API to Render and VPS
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- Build API image
7+
branches:
8+
- main
9+
types:
10+
- completed
11+
12+
jobs:
13+
deploy-render:
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
16+
steps:
17+
- name: install curl
18+
run: sudo apt-get update && sudo apt-get install -y curl
19+
- name: send Render API deploy webhook
20+
run: curl ${{ secrets.RENDER_WEBHOOK }}
21+
deploy-vps:
22+
runs-on: ubuntu-latest
23+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
- name: Remove old container
28+
run: |
29+
echo ${{ secrets.FROG_KEY }} | base64 -d > frog &&
30+
chmod 600 frog &&
31+
ssh -o StrictHostKeyChecking=no -i frog ${{ secrets.FROG_ADDRESS }} -p${{ secrets.FROG_PORT }} "docker rm -f flush-log-api" || true
32+
33+
- name: Remove old image
34+
run: |
35+
echo ${{ secrets.FROG_KEY }} | base64 -d > frog &&
36+
chmod 600 frog &&
37+
ssh -o StrictHostKeyChecking=no -i frog ${{ secrets.FROG_ADDRESS }} -p${{ secrets.FROG_PORT }} "docker image rm ghcr.io/pgulb/flush-log:api" || true
38+
39+
- name: Deploy fresh container
40+
run: |
41+
echo ${{ secrets.FROG_KEY }} | base64 -d > frog &&
42+
chmod 600 frog &&
43+
ssh -o StrictHostKeyChecking=no -i frog ${{ secrets.FROG_ADDRESS }} -p${{ secrets.FROG_PORT }} "docker run -d -p 30149:6789 -e MONGO_URL='${{ secrets.MONGO_URL }}' --name flush-log-api --restart=unless-stopped ghcr.io/pgulb/flush-log:api"

0 commit comments

Comments
 (0)