-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
394 additions
and
51 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Prod deploy | ||
on: push | ||
|
||
jobs: | ||
messenger-demo-deploy: | ||
environment: prod | ||
runs-on: ubuntu-latest | ||
if: ${{ contains( github.ref, vars.TRIGGER_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: Declare some variables | ||
shell: bash | ||
run: | | ||
echo ${{ contains( github.ref, vars.TRIGGER_BRANCH) }} | ||
echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV" | ||
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> "$GITHUB_ENV" | ||
echo "now=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV | ||
- name: Prepare SSH | ||
run: | | ||
mkdir ~/.ssh | ||
echo "${{ secrets.HOST_SSH_PUBLIC_KEY }}" > ~/.ssh/known_hosts | ||
echo "${{ secrets.DO_SSH_KEY }}" > ./ssh-key | ||
chmod 600 ./ssh-key | ||
- name: Create .env file | ||
env: | ||
TARGET_HOST: ${{ secrets.HOST_DOMAIN}} | ||
run: | | ||
echo "REACT_APP_ADDR_ENS_SUBDOMAIN=.beta-addr.dm3.eth" >> ./.env.react | ||
echo "REACT_APP_BACKEND=http://${{ secrets.HOST_DOMAIN}}/api" >> ./.env.react | ||
echo "REACT_APP_DEFAULT_DELIVERY_SERVICE=beta-ds.dm3.eth" >> ./.env.react | ||
echo "REACT_APP_DEFAULT_SERVICE=http://${{ secrets.HOST_DOMAIN}}/api" >> ./.env.react | ||
echo "REACT_APP_ETHEREUM_PROVIDER=${{ secrets.RPC }}" >> ./.env.react | ||
echo "REACT_APP_PROFILE_BASE_URL=http://${{ secrets.HOST_DOMAIN}}/api" >> ./.env.react | ||
echo "REACT_APP_RESOLVER_BACKEND=http://${{ secrets.HOST_DOMAIN}}/resolver-handler" >> ./.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 "REACT_APP_COMMIT_HASH=${{ env.sha_short }}" >> ./.env.react | ||
echo "REACT_APP_BRANCH=${{ env.branch }}" >> ./.env.react | ||
echo "REACT_APP_BUILD_TIME=${{ env.now }}" >> ./.env.react | ||
cat ./.env.react >> ./.env | ||
echo "RESOLVER_ADDR=0xae6646c22D8eE6479eE0a39Bf63B9bD9e57bAD9d" >> ./.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/prod/nginx.conf > ./nginx.conf | ||
cat ./.env | ||
- 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: Prepare docker | ||
run: | | ||
ssh -i ./ssh-key app@${{ secrets.HOST_DOMAIN}} "\ | ||
cd dm3 && docker compose down && docker system prune -af" | ||
ssh -i ./ssh-key root@${{ secrets.HOST_DOMAIN}} "\ | ||
systemctl restart docker.service \ | ||
rm /home/app/dm3-backend.tar || true" | ||
- name: Sync files | ||
run: | | ||
rsync -avz -e 'ssh -i ./ssh-key' ./.env app@${{ secrets.HOST_DOMAIN}}:/home/app/dm3 | ||
rsync -avz -e 'ssh -i ./ssh-key' ./dm3-backend.tar app@${{ secrets.HOST_DOMAIN}}:/home/app/dm3 | ||
rsync -avz -e 'ssh -i ./ssh-key' ./nginx.conf app@${{ secrets.HOST_DOMAIN}}:/home/app/dm3 | ||
rsync -avz -e 'ssh -i ./ssh-key' ./docker/prod/docker-compose.yml app@${{ secrets.HOST_DOMAIN}}:/home/app/dm3 | ||
- name: Load docker image | ||
run: | | ||
ssh -i ./ssh-key app@${{ secrets.HOST_DOMAIN}} "\ | ||
cd dm3 && docker load -i dm3-backend.tar" | ||
- name: Firewall config | ||
run: | | ||
ssh -i ./ssh-key root@${{ secrets.HOST_DOMAIN}} "\ | ||
ufw allow from 172.18.0.1/16 proto tcp to ${{ secrets.HOST_DOMAIN}} port 80" | ||
- name: Start | ||
run: | | ||
ssh -i ./ssh-key app@${{ secrets.HOST_DOMAIN}} "\ | ||
cd dm3 && docker compose --env-file .env up -d" |
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
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
Oops, something went wrong.