Add nginx reloading if ssl updatet #55
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: Deploy | |
on: | |
push: | |
branches: [ "devops/55-nginx-reloading" ] | |
jobs: | |
build: | |
environment: main | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Create Image Tarball for explorer-frontend | |
run: | | |
docker build --build-arg GIT_COMMIT_SHA=$(git rev-parse --short HEAD) --build-arg GIT_TAG=$(git describe --tags --abbrev=0) -t explorer-frontend . | |
docker save -o explorer-frontend.tar explorer-frontend | |
mkdir -p artifacts | |
mv explorer-frontend.tar artifacts/ | |
- name: Create Image Tarball for nginx | |
run: | | |
docker build --build-arg GIT_COMMIT_SHA=$(git rev-parse --short HEAD) --build-arg GIT_TAG=$(git describe --tags --abbrev=0) -t nginx-explorer nginx-docker/ | |
docker save -o nginx-explorer.tar nginx-explorer | |
mv nginx-explorer.tar artifacts/ | |
- name: Set up SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
touch ~/.ssh/known_hosts | |
ssh-keyscan ${{ secrets.EXPLORER_HOST }} >> ~/.ssh/known_hosts | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
eval $(ssh-agent) | |
- name: Copy Files to Server | |
run: | | |
scp -r artifacts/* ${{ secrets.HOST_USER}}@${{ secrets.EXPLORER_HOST }}:/blockscout/ | |
scp -r deploy/* ${{ secrets.HOST_USER}}@${{ secrets.EXPLORER_HOST }}:/blockscout/ | |
- name: SSH into Server and Deploy | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EXPLORER_HOST }} | |
username: ${{ secrets.HOST_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
cd /blockscout | |
docker load -i explorer-frontend.tar | |
docker load -i nginx-explorer.tar | |
docker compose down | |
docker compose pull | |
docker compose up -d --build --remove-orphans |