Merge pull request #9 from ls1intum/tum-deploy #1
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 Reverse Proxy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'reverse-proxy/**' | |
| - '.github/workflows/reverse-proxy.yml' | |
| jobs: | |
| build: | |
| if: ${{ vars.ENABLE_DEPLOYMENT == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and Push Reverse Proxy Image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: linux/amd64, linux/arm64 | |
| context: reverse-proxy | |
| file: reverse-proxy/Dockerfile | |
| tags: ghcr.io/ls1intum/angelosai/custom-openresty:latest | |
| push: true | |
| no-cache: true | |
| deploy: | |
| if: ${{ vars.ENABLE_DEPLOYMENT == 'true' }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| # Copy Reverse Proxy Compose file to the VM | |
| - name: Copy Reverse Proxy Compose to VM | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ vars.VM_HOST }} | |
| username: ${{ vars.VM_USERNAME }} | |
| key: ${{ secrets.VM_SSH_PRIVATE_KEY }} | |
| proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }} | |
| proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }} | |
| proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }} | |
| proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }} | |
| source: "reverse-proxy/docker-compose.yml" | |
| target: "/home/${{ vars.VM_USERNAME }}/${{ github.repository }}/reverse-proxy/" | |
| # Copy Reverse Proxy nginx.conf to the VM | |
| - name: Copy Reverse Proxy nginx.conf to VM | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ vars.VM_HOST }} | |
| username: ${{ vars.VM_USERNAME }} | |
| key: ${{ secrets.VM_SSH_PRIVATE_KEY }} | |
| proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }} | |
| proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }} | |
| proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }} | |
| proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }} | |
| source: "reverse-proxy/nginx.conf" | |
| target: "/home/${{ vars.VM_USERNAME }}/${{ github.repository }}/reverse-proxy/" | |
| - name: SSH to VM and Start Reverse Proxy | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ vars.VM_HOST }} | |
| username: ${{ vars.VM_USERNAME }} | |
| key: ${{ secrets.VM_SSH_PRIVATE_KEY }} | |
| proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }} | |
| proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }} | |
| proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }} | |
| proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }} | |
| script: | | |
| cd /home/${{ vars.VM_USERNAME }}/${{ github.repository }}/reverse-proxy | |
| docker compose pull nginx-proxy || true | |
| docker compose up -d --force-recreate --remove-orphans | |
| docker ps |