/role command #29
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 v2 | |
on: | |
push: | |
branches: | |
- schism | |
workflow_dispatch: | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Mold Linker | |
uses: rui314/setup-mold@v1 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
- name: Install sccache | |
uses: mozilla-actions/sccache-action@v0.0.3 | |
- name: Install nushell | |
uses: hustcer/setup-nu@v3.8 | |
with: | |
version: "*" | |
- name: Setup Rust Cache | |
id: rust-cache | |
uses: actions/cache@v3 | |
with: | |
key: ${{ runner.os }}-rust-cache | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
- name: Pre-build GHA Scripts | |
run: | | |
echo RUSTC_WRAPPER=sccache >> $GITHUB_ENV | |
echo SCCACHE_GHA_ENABLED=true >> $GITHUB_ENV | |
sudo ln -s /usr/local/bin/mold /usr/bin/mold | |
echo "${{ secrets.DOTENV_V2 }}" > .env | |
sccache --show-stats | |
- name: Run build script | |
run: | | |
nu scripts/build.nu --release | |
- name: Login to docker hub | |
run: docker login -u onlycs -p ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push dockerfiles | |
run: docker compose build --push | |
- name: Save ssh keys | |
run: | | |
echo "${{ secrets.SSH_KEY }}" > ssh_key | |
chmod 600 ssh_key | |
echo "DO_SSH=ssh -i ssh_key onlycs@${{ secrets.SSH_HOST }} -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR" >> $GITHUB_ENV | |
- name: Kill and remove old docker container | |
continue-on-error: true | |
run: | | |
$DO_SSH "cd ~/.oreo2; docker compose down" | |
- name: Save and run compose | |
continue-on-error: true | |
run: $DO_SSH "cd ~/.oreo2; docker compose up --pull always -d" |