Merge pull request #84 from RealToken-Community/vefa-current-time-not… #58
This file contains 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: Test and deploy to branch | |
on: | |
push: | |
branches: | |
- master | |
- preprod | |
- develop | |
jobs: | |
validate: | |
name: Validate branch | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
- name: Install dependencies | |
run: npm install | |
- name: Lint | |
run: npm run lint | |
- name: Prettier | |
run: npm run prettier:check | |
- name: Build | |
run: npm run build | |
deploy: | |
name: Deploy to branch | |
runs-on: ubuntu-latest | |
needs: validate | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.DOCKER_REGISTRY }} | |
username: ${{ secrets.DOCKER_LOGIN }} | |
password: ${{ secrets.DOCKER_PASSWD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ secrets.DOCKER_REGISTRY }}/dashboard:${{ github.ref_name }} | |
- name: Configure SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$SSH_KEY" > ~/.ssh/staging.key | |
chmod 600 ~/.ssh/staging.key | |
cat >>~/.ssh/config <<END | |
Host staging | |
HostName $SSH_HOST | |
User $SSH_USER | |
Port $SSH_PORT | |
IdentityFile ~/.ssh/staging.key | |
StrictHostKeyChecking no | |
END | |
env: | |
SSH_USER: ${{ secrets.SSH_USER }} | |
SSH_KEY: ${{ secrets.SSH_KEY }} | |
SSH_HOST: ${{ secrets.SSH_HOST }} | |
SSH_PORT: ${{ secrets.SSH_PORT }} | |
- name: Update branch environment | |
run: | | |
ssh staging 'export DOCKER_BRANCH=${{ github.ref_name }} DOCKER_REGISTRY=${{ secrets.DOCKER_REGISTRY }} | |
cd /var/docker/dashboard-v2/${DOCKER_BRANCH} | |
git pull origin ${DOCKER_BRANCH} | |
docker compose --file docker-compose-branch.yml pull | |
docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWD }} ${DOCKER_REGISTRY} | |
THEGRAPH_API_KEY=${{ secrets.THEGRAPH_API_KEY }} \ | |
COMMUNITY_API_KEY=${{ secrets.COMMUNITY_API_KEY }} \ | |
HOSTNAME=${{ github.ref_name == 'master' && 'dashboard.realt.community' || 'dashboard.${DOCKER_BRANCH}.realt.community' }} \ | |
docker compose --project-name ${{ github.ref_name }}-dashboard --file docker-compose-branch.yml up -d' |