Merge pull request #176 from AndrewCS149/testWorkflow #27
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 to Staging | |
on: | |
workflow_dispatch: | |
inputs: | |
input: | |
required: false | |
push: | |
branches: | |
- staging | |
jobs: | |
deploy-to-staging: | |
name: Deploy to Staging | |
runs-on: ubuntu-latest | |
environment: staging | |
steps: | |
- name: Cache Trunk | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cargo | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- uses: actions/checkout@v3 | |
- name: Set up Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: wasm32-unknown-unknown | |
toolchain: stable | |
- name: Install Trunk | |
run: cargo install trunk | |
# if: steps.cache.outputs.cache-hit != 'true' | |
- name: Build with Trunk | |
run: trunk build --release | |
working-directory: client | |
- name: Create SSH Key | |
run: | | |
mkdir -p ${{ secrets.SSH_PRIVATE_KEY_PATH }} | |
echo "${{ secrets.SSH_PRIVATE_KEY_CONTENT }}" > ${{ secrets.SSH_PRIVATE_KEY_PATH }}/${{ secrets.SSH_PRIVATE_KEY_NAME }} | |
sudo chmod 600 ${{ secrets.SSH_PRIVATE_KEY_PATH }}/${{ secrets.SSH_PRIVATE_KEY_NAME }} | |
shell: bash | |
- name: Add Host Key to known_hosts | |
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ${{ secrets.SSH_PRIVATE_KEY_PATH }}/known_hosts | |
- name: Copy Files to Server | |
run: scp -i ${{ secrets.SSH_PRIVATE_KEY_PATH }}/${{ secrets.SSH_PRIVATE_KEY_NAME }} -r client/dist ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ vars.DEVBLOG_ROOT_PATH }}/client | |
- name: Restart Container | |
run: | | |
ssh -i ${{ secrets.SSH_PRIVATE_KEY_PATH }}/${{ secrets.SSH_PRIVATE_KEY_NAME }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "\ | |
cd ${{ vars.DEVBLOG_ROOT_PATH }}/../ && \ | |
docker container rm -f ${{ vars.DEVBLOG_CONTAINER }} || true && \ | |
docker compose up -d" | |