-
Notifications
You must be signed in to change notification settings - Fork 0
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
3 changed files
with
144 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Rust CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
- main | ||
|
||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
|
||
- name: Toolchain info | ||
run: | | ||
cargo --version --verbose | ||
rustc --version | ||
cargo clippy --version | ||
- name: Install prebuild binaries of cargo-make | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cargo-make | ||
|
||
- name: Run Format | ||
run: cargo make format | ||
|
||
- name: Run Build | ||
run: cargo make build | ||
|
||
deploy: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Get Commit SHA | ||
run: | | ||
echo "Commit SHA: ${{ github.sha }}" | ||
- name: rsync deployments | ||
uses: burnett01/[email protected] | ||
with: | ||
switches: -avzr --delete --exclude=.github --exclude=data --exclude=target --exclude=.env --exclude=.env.dist --exclude=.env.test --exclude=mocks --exclude=.git | ||
path: . | ||
remote_path: /root/l2-indexer | ||
remote_host: ${{ secrets.SSH_HOST }} | ||
remote_user: root | ||
remote_key: ${{ secrets.SSH_DEPLOY_KEY }} | ||
|
||
# - name: Run docker-compose on server | ||
- name: Setup envs and run docker-compose on server | ||
run: | | ||
echo "${{ secrets.SSH_DEPLOY_KEY }}" > ./l2-indexer.pem &&\ | ||
chmod 600 ./l2-indexer.pem &&\ | ||
ssh -o StrictHostKeyChecking=no -i ./l2-indexer.pem root@${{ secrets.SSH_HOST }} "\ | ||
echo -e '## Git sha: ${{ github.sha }}\nDate UNIX: $(date +%s)\n' >> version.md &&\ | ||
echo '${{ secrets.ENV_CONFIG }}' > /root/l2-indexer/.env &&\ | ||
docker image prune -f &&\ | ||
docker builder prune -f &&\ | ||
cargo make setup" | ||
shell: bash |
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,57 @@ | ||
echo "DOCKER" &&\ | ||
sudo apt update &&\ | ||
sudo apt install docker.io -y &&\ | ||
sudo systemctl enable docker &&\ | ||
sudo systemctl start docker &&\ | ||
sudo usermod -aG docker ${USER} &&\ | ||
|
||
echo "DOCKER-COMPOSE" &&\ | ||
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose &&\ | ||
sudo chmod +x /usr/local/bin/docker-compose &&\ | ||
|
||
echo "RUST" &&\ | ||
sudo apt install build-essential -y &&\ | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh &&\ | ||
source "$HOME/.cargo/env" &&\ | ||
cargo install --force cargo-make &&\ | ||
|
||
echo "PM2" &&\ | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash &&\ | ||
source ~/.bashrc &&\ | ||
nvm install 22 &&\ | ||
npm install pm2 -g &&\ | ||
pm2 startup &&\ | ||
|
||
echo "NGINX" &&\ | ||
sudo apt update -y &&\ | ||
sudo apt install nginx git make -y &&\ | ||
sudo systemctl enable nginx &&\ | ||
sudo systemctl start nginx &&\ | ||
|
||
echo "CERTBOT" &&\ | ||
sudo apt install python3-venv python3-pip -y &&\ | ||
sudo python3 -m venv /opt/certbot/ &&\ | ||
sudo /opt/certbot/bin/pip install --upgrade pip &&\ | ||
sudo /opt/certbot/bin/pip install certbot certbot-nginx &&\ | ||
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot &&\ | ||
sudo certbot --version &&\ | ||
|
||
echo "HTTPS (NGINX + CERTBOT)" &&\ | ||
echo "user www-data; | ||
worker_processes auto; | ||
events { | ||
worker_connections 1024; | ||
} | ||
http { | ||
server { | ||
server_name l2-indexer.api.herodotus.cloud; | ||
location / { | ||
proxy_set_header X-Forwarded-For \$remote_addr; | ||
proxy_set_header Host \$http_host; | ||
proxy_pass \"http://0.0.0.0:8000\"; | ||
} | ||
} | ||
}" > tmp.conf && sudo cp tmp.conf /etc/nginx/nginx.conf && rm tmp.conf &&\ | ||
sudo certbot --nginx -d l2-indexer.api.herodotus.cloud --non-interactive --agree-tos --email [email protected] |
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