Skip to content

build: staging conf #32

build: staging conf

build: staging conf #32

Workflow file for this run

name: Push Workflow
on: push
jobs:
messenger-demo-deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/${{ vars.STAGING_BRANCH }}'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
registry-url: 'https://npm.pkg.github.com'
node-version: 18.0.0
cache: 'yarn'
- name: Prepare SSH
run: |
mkdir ~/.ssh
echo "${{ secrets.STAGING_HOST_SSH }}" > ~/.ssh/known_hosts
echo "${{ secrets.DO_SSH_KEY }}" > ./ssh-key
chmod 600 ./ssh-key
- name: Create .env file
env:
TARGET_HOST: ${{ secrets.STAGING_HOST }}
run: |
echo "REACT_APP_ADDR_ENS_SUBDOMAIN=.beta-addr.dm3.eth" >> ./.env.react
echo "REACT_APP_BACKEND=http://${{ secrets.STAGING_HOST }}" >> ./.env.react
echo "REACT_APP_DEFAULT_DELIVERY_SERVICE=beta-ds.dm3.eth" >> ./.env.react
echo "REACT_APP_DEFAULT_SERVICE=http://${{ secrets.STAGING_HOST }}" >> ./.env.react
echo "REACT_APP_ETHEREUM_PROVIDER=${{ secrets.REACT_APP_ETHEREUM_PROVIDER }}" >> ./.env.react
echo "REACT_APP_PROFILE_BASE_URL=http://${{ secrets.STAGING_HOST }}/resolver" >> ./.env.react
echo "REACT_APP_RESOLVER_BACKEND=http://${{ secrets.STAGING_HOST }}/resolver" >> ./.env.react
echo "REACT_APP_USER_ENS_SUBDOMAIN=.beta-user.dm3.eth" >> ./.env.react
echo "REACT_APP_WALLET_CONNECT_PROJECT_ID=${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}" >> ./.env.react
echo "RESOLVER_ADDR=0x45F7Ed7d05c563D408898A80d9C705CC3328D2EF" >> ./.env
echo "SIGNING_PUBLIC_KEY=${{ secrets.SIGNING_PUBLIC_KEY }}" >> ./.env
echo "SIGNING_PRIVATE_KEY=${{ secrets.SIGNING_PRIVATE_KEY }}" >> ./.env
echo "SIGNER_PRIVATE_KEY=${{ secrets.SIGNER_PRIVATE_KEY }}" >> ./.env
echo "SPAM_PROTECTION=${{ secrets.SPAM_PROTECTION }}" >> ./.env
echo "ENCRYPTION_PUBLIC_KEY=${{ secrets.ENCRYPTION_PUBLIC_KEY }}" >> ./.env
echo "ENCRYPTION_PRIVATE_KEY=${{ secrets.ENCRYPTION_PRIVATE_KEY }}" >> ./.env
echo "RPC=${{ secrets.RPC }}" >> ./.env
envsubst '${SSL_CERTIFICATE_BASE_LOC} ${TLS_CERTIFICATE_LOCATION} ${TARGET_HOST}' < ./docker/nginx.conf > ./nginx.conf
- name: Build docker image
run: |
cp ./.env.react packages/messenger-demo/.env
docker build --progress=plain -t dm3-backend:latest -f ./docker/Dockerfile .
docker save -o ./dm3-backend.tar dm3-backend:latest
- name: Sync files
run: |
rsync -avz -e 'ssh -i ./ssh-key' ./.env app@${{ secrets.STAGING_HOST }}:/home/app/dm3
rsync -avz -e 'ssh -i ./ssh-key' ./dm3-backend.tar app@${{ secrets.STAGING_HOST }}:/home/app/dm3
rsync -avz -e 'ssh -i ./ssh-key' ./nginx.conf app@${{ secrets.STAGING_HOST }}:/home/app/dm3
rsync -avz -e 'ssh -i ./ssh-key' ./docker/docker-compose.yml app@${{ secrets.STAGING_HOST }}:/home/app/dm3
- name: Load image
run: |
ssh -i ./ssh-key app@${{ secrets.STAGING_HOST }} "\
cd dm3 && docker load -i dm3-backend.tar; \
rm dm3-backend.tar"
- name: Start
run: |
ssh -i ./ssh-key app@${{ secrets.STAGING_HOST }} "\
cd dm3 && docker compose down && docker compose --env-file .env up -d"