name: Build and Deploy Gateway on: push: branches: [master] workflow_dispatch: env: DEPLOY_PATH: /opt/vpn-proxy jobs: build-and-deploy: runs-on: lxc-111 steps: - name: Clone repository env: GIT_TOKEN: ${{ secrets.REGISTRY_TOKEN }} run: | set -euo pipefail SERVER_HOST=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||') rm -rf repo git clone --depth 2 "http://${{ gitea.actor }}:${GIT_TOKEN}@${SERVER_HOST}/${{ gitea.repository }}.git" repo cd repo git checkout ${{ gitea.sha }} - name: Build and push gateway image run: | set -euo pipefail cd repo REGISTRY_HOST=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||') IMAGE="${REGISTRY_HOST}/${{ gitea.repository }}/gateway" echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$REGISTRY_HOST" -u "${{ gitea.actor }}" --password-stdin DOCKER_BUILDKIT=1 docker build \ --network host \ -t "${IMAGE}:latest" \ -t "${IMAGE}:${{ gitea.sha }}" \ . docker push "${IMAGE}:latest" docker push "${IMAGE}:${{ gitea.sha }}" - name: Deploy gateway to LXC 111 run: | set -euo pipefail cd repo REGISTRY_HOST=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||') IMAGE="${REGISTRY_HOST}/${{ gitea.repository }}/gateway" DEPLOY_PATH="${{ env.DEPLOY_PATH }}" GATEWAY_IMAGE="${IMAGE}:latest" bash scripts/deploy-gateway.sh