Deploy on Successful Build Proxmox #323
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 Successful Build Proxmox | |
on: | |
workflow_run: | |
workflows: ["Rust"] | |
types: | |
- completed | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Exit if the branch is not master | |
run: | | |
if [[ "${{ github.ref }}" != "refs/heads/main" ]]; then | |
echo "Branch is not master, exiting." | |
exit 0 | |
fi | |
- name: Setup Cloudflared | |
run: | | |
curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb | |
sudo dpkg -i cloudflared.deb | |
shell: bash | |
- name: Setup ssh cloudflared config | |
run: | | |
mkdir -p ~/.ssh | |
printf "Host sshtransit03.catenarymaps.org\nProxyCommand /usr/bin/cloudflared access ssh --hostname %%h" > ~/.ssh/config | |
echo "${{ secrets.REMOTE_SERVER }}" > ~/.ssh/known_hosts | |
shell: bash | |
- name: Setup SSH Key | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 | |
chmod 600 ~/.ssh/id_ed25519 | |
shell: bash | |
- name: SSH | |
run: | | |
ssh [email protected] "echo '${{ secrets.SUDO_PASSWD }}' | sudo -S bash -c 'chown -R lolpro11 /opt/catenary-backend; rm /opt/catenary-backend/Cargo.lock'; echo '${{ secrets.SUDO_PASSWD }}' | sudo -S -u lolpro11 bash -c 'cd /opt/catenary-backend; git pull; cargo clean --verbose; cargo build --release --verbose'; echo '${{ secrets.SUDO_PASSWD }}' | sudo -S systemctl restart transitbackend.service" | |
shell: bash |