Deploy API to Render and VPS #104
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 API to Render and VPS | |
on: | |
workflow_run: | |
workflows: | |
- Build API image | |
branches: | |
- main | |
types: | |
- completed | |
jobs: | |
deploy-render: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: install curl | |
run: sudo apt-get update && sudo apt-get install -y curl | |
- name: send Render API deploy webhook | |
run: curl ${{ secrets.RENDER_WEBHOOK }} | |
deploy-vps: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Remove old container | |
run: | | |
echo ${{ secrets.FROG_KEY }} | base64 -d > frog && | |
chmod 600 frog && | |
ssh -o StrictHostKeyChecking=no -i frog ${{ secrets.FROG_ADDRESS }} -p${{ secrets.FROG_PORT }} "docker rm -f flush-log-api" || true | |
- name: Remove old image | |
run: | | |
echo ${{ secrets.FROG_KEY }} | base64 -d > frog && | |
chmod 600 frog && | |
ssh -o StrictHostKeyChecking=no -i frog ${{ secrets.FROG_ADDRESS }} -p${{ secrets.FROG_PORT }} "docker image rm ghcr.io/pgulb/flush-log:api" || true | |
- name: Deploy fresh container | |
run: | | |
echo ${{ secrets.FROG_KEY }} | base64 -d > frog && | |
chmod 600 frog && | |
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" |