Skip to content

Fix migrations execution issue #176

Fix migrations execution issue

Fix migrations execution issue #176

name: staging-pipeline
on:
push:
branches:
- staging
pull_request:
branches:
- staging
jobs:
test:
runs-on: ubuntu-latest
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6490:6379
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: givethio
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5446:5432
steps:
- uses: actions/checkout@v1
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 20.14.0
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: Run linter
run: yarn lint
- name: Wait for PostgreSQL to be ready
run: |
until pg_isready -h localhost -p 5432; do
echo "Waiting for PostgreSQL to be ready..."
sleep 1
done
- name: Check and Create Database if it doesn't exist
run: |
psql -U postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'notification-center'" | grep -q 1 || psql -U postgres -c "CREATE DATABASE \"notification-center\";"
- name: Run migrations
run: yarn db:migrate:run:test
- name: Run tests
run: yarn test
publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Install Yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: Build image and push to GitHub Packages
uses: docker/build-push-action@v1
with:
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ghcr.io
repository: giveth/notification-center
add_git_labels: true
# Add branch name to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref}
tag_with_ref: true
# Add commit hash to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha}
tag_with_sha: true
deploy:
needs: publish
runs-on: ubuntu-latest
steps:
- name: SSH and Redeploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST_ALL }}
username: ${{ secrets.STAGING_USERNAME_ALL }}
key: ${{ secrets.STAGING_PRIVATE_KEY_ALL }}
port: ${{ secrets.SSH_PORT }}
script: |
cd giveth-all
docker-compose stop notification-center
docker-compose pull notification-center
docker-compose up -d notification-center
docker image prune -a --force