Skip to content

[Snyk] Upgrade mongoose from 8.4.0 to 8.5.0 #4403

[Snyk] Upgrade mongoose from 8.4.0 to 8.5.0

[Snyk] Upgrade mongoose from 8.4.0 to 8.5.0 #4403

name: Build and Publish
on:
push:
paths-ignore:
- 'tests/**'
branches:
- main
pull_request:
paths-ignore:
- 'tests/**'
branches:
- main
workflow_dispatch:
jobs:
build-and-push-docker-image:
name: Build Docker image and push to repositories
runs-on: ubuntu-latest
outputs:
sha_version: ${{ steps.vars.outputs.sha_short }}
commit_msg: ${{ steps.vars.outputs.commit_msg }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set outputs
id: vars
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
echo "::set-output name=commit_msg::$(git log -1 --pretty=format:\"%s\")"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Generate container version
id: docker_build_version
env:
GITHUB_RUN_NUMBER: ${{ github.run_number }}
run: echo "::set-output name=version::$(date +'%Y-%m-%d').$GITHUB_RUN_NUMBER"
- name: Build container image and push to Docker Hub
uses: docker/build-push-action@v4
with:
context: .
load: false
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/pathology:latest
${{ secrets.DOCKERHUB_USERNAME }}/pathology:${{ steps.vars.outputs.sha_short }}
${{ secrets.DOCKERHUB_USERNAME }}/pathology:${{ steps.docker_build_version.outputs.version }}
${{ secrets.DOCKERHUB_USERNAME }}/pathology-socket:latest
${{ secrets.DOCKERHUB_USERNAME }}/pathology-socket:${{ steps.vars.outputs.sha_short }}
${{ secrets.DOCKERHUB_USERNAME }}/pathology-socket:${{ steps.docker_build_version.outputs.version }}
push: ${{ github.ref == 'refs/heads/main' }}
config:
name: Config
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
get-server-ip-list: ${{ steps.get-server-ip-list.outputs.get-server-ip-list }}
steps:
- id: get-server-ip-list
name: Get Server IP List
run: echo "get-server-ip-list=$(dig +short app-servers.thinky.gg TXT | jq -cr 'split(",")')" >> $GITHUB_OUTPUT
- name: print output
run: |
echo "${{ steps.get-server-ip-list.outputs.get-server-ip-list }}"
deploy-to-staging:
name: Deploy to Staging
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [build-and-push-docker-image, config]
strategy:
matrix:
server: ${{ fromJson(needs.config.outputs.get-server-ip-list) }}
steps:
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/pathology
chmod 600 ~/.ssh/pathology
cat >>~/.ssh/config <<END
Host *
User $SSH_USER
IdentityFile ~/.ssh/pathology
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.SERVER_SSH_USER }}
SSH_KEY: ${{ secrets.SERVER_SSH_KEY }}
- name: Update Environments with New Containers
run: ssh ${{ matrix.server }} 'bash /opt/pathology/scripts/update-Environments.sh -e stage -v ${{ needs.build-and-push-docker-image.outputs.sha_version }}'