diff --git a/.github/workflows/build-push-image.yaml b/.github/workflows/build-push-image.yaml new file mode 100644 index 00000000..b5913b37 --- /dev/null +++ b/.github/workflows/build-push-image.yaml @@ -0,0 +1,42 @@ +name: Build Image +permissions: read-all + +on: + workflow_call: + inputs: + environment: + required: true + type: string + image_tag: + required: true + type: string + +jobs: + push_to_registry_env: + name: Push Docker Image to Docker Hub + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: willnilges/meshdb + + - name: Build and push Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ inputs.image_tag }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/deploy-to-k8s.yaml b/.github/workflows/deploy-to-k8s.yaml index 51008042..b6000a33 100644 --- a/.github/workflows/deploy-to-k8s.yaml +++ b/.github/workflows/deploy-to-k8s.yaml @@ -7,6 +7,9 @@ on: environment: required: true type: string + useTag: + required: false + type: string jobs: deploy_to_k8s: @@ -33,6 +36,9 @@ jobs: sudo ip address add dev wg1 ${{ secrets.WIREGUARD_OVERLAY_NETWORK_IP }} peer ${{ secrets.SSH_TARGET_IP }} sudo wg set wg1 listen-port 48123 private-key privatekey peer ${{ secrets.WIREGUARD_PEER_PUBLIC_KEY }} allowed-ips 0.0.0.0/0 endpoint ${{ secrets.WIREGUARD_ENDPOINT }} sudo ip link set up dev wg1 + + # Ensure we can contact the target + ping ${{ secrets.SSH_TARGET_IP }} -w 4 || exit 1 - name: Deploy Helm Chart run: | @@ -75,7 +81,8 @@ jobs: --set meshweb.osticket_new_ticket_endpoint="${{ vars.OSTICKET_NEW_TICKET_ENDPOINT }}" \ --set meshweb.environment="${{ inputs.environment }}" \ --set ingress.hosts[0].host="${{ vars.INGRESS_HOST }}",ingress.hosts[0].paths[0].path=/,ingress.hosts[0].paths[0].pathType=Prefix \ - --set ingress.hosts[1].host="${{ vars.INGRESS_HOST_LEGACY }}",ingress.hosts[1].paths[0].path=/,ingress.hosts[1].paths[0].pathType=Prefix + --set ingress.hosts[1].host="${{ vars.INGRESS_HOST_LEGACY }}",ingress.hosts[1].paths[0].path=/,ingress.hosts[1].paths[0].pathType=Prefix \ + --set meshweb.image.tag="${{ inputs.useTag }}" # Rolling restart kubectl --kubeconfig ./config --server https://${{ secrets.SSH_TARGET_IP }}:6443 -n ${{ vars.APP_NAMESPACE }} rollout restart deploy diff --git a/.github/workflows/publish-and-deploy-gamma.yaml b/.github/workflows/publish-and-deploy-gamma.yaml new file mode 100644 index 00000000..199b51f2 --- /dev/null +++ b/.github/workflows/publish-and-deploy-gamma.yaml @@ -0,0 +1,36 @@ +name: Publish and Deploy Gamma + +on: + push: + branches: [ dev ] + workflow_dispatch: + branches: + - dev + +permissions: read-all + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + push_to_registry_gamma: + name: Push to gamma1 + uses: ./.github/workflows/build-push-image.yaml + with: + environment: gamma1 + image_tag: willnilges/meshdb:gamma1 + secrets: inherit + if: github.ref == 'refs/heads/dev' + + deploy_to_gamma1: + name: Deploy to gamma1 + uses: ./.github/workflows/deploy-to-k8s.yaml + with: + environment: gamma1 + useTag: gamma1 + secrets: inherit + needs: push_to_registry_gamma + if: github.ref == 'refs/heads/dev' + + diff --git a/.github/workflows/publish-and-deploy.yaml b/.github/workflows/publish-and-deploy.yaml index f8112bce..ce0315f5 100644 --- a/.github/workflows/publish-and-deploy.yaml +++ b/.github/workflows/publish-and-deploy.yaml @@ -44,11 +44,22 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + #deploy_to_gamma1: + # name: Deploy to gamma1 + # uses: ./.github/workflows/deploy-to-k8s.yaml + # with: + # environment: gamma1 + # useTag: gamma1 + # secrets: inherit + # needs: push_to_registry + # if: github.ref == 'refs/heads/main' + deploy_to_dev3: name: Deploy to dev 3 uses: ./.github/workflows/deploy-to-k8s.yaml with: environment: dev3 + useTag: main secrets: inherit needs: push_to_registry if: github.ref == 'refs/heads/main' @@ -67,6 +78,7 @@ jobs: uses: ./.github/workflows/deploy-to-k8s.yaml with: environment: prod2 + useTag: main secrets: inherit needs: integration_test_dev3 if: github.ref == 'refs/heads/main' diff --git a/src/meshdb/settings.py b/src/meshdb/settings.py index 44377f4b..9965a54b 100644 --- a/src/meshdb/settings.py +++ b/src/meshdb/settings.py @@ -134,6 +134,7 @@ "meshdb", "nginx", "devdb.nycmesh.net", + "gammadb.nycmesh.net", ] CORS_ALLOWED_ORIGINS = [ @@ -142,6 +143,7 @@ "https://adminmap.db.nycmesh.net", "https://adminmap.devdb.nycmesh.net", "https://devdb.nycmesh.net", + "https://gammadb.nycmesh.net", ] CORS_ALLOW_HEADERS = [ @@ -156,6 +158,7 @@ "http://nginx:8080", "https://db.nycmesh.net", "https://devdb.nycmesh.net", + "https://gammadb.nycmesh.net", ] if DEBUG: