dl primer info #142
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: Build & Test | |
on: | |
pull_request: | |
types: [opened, edited, synchronize, reopened] | |
branches: [master, develop] | |
push: | |
branches: [master, develop] | |
jobs: | |
deploy: | |
if: github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master') | |
runs-on: ubuntu-latest | |
env: | |
SSH_ADDRESS: ${{ github.ref == 'refs/heads/master' && secrets.SSH_ADDRESS_PROD || secrets.SSH_ADDRESS }} | |
SSH_USER: ${{ github.ref == 'refs/heads/master' && secrets.SSH_USER_PROD || secrets.SSH_USER }} | |
SSH_KEY: ${{ github.ref == 'refs/heads/master' && secrets.SSH_KEY_PROD || secrets.SSH_KEY }} | |
DEPLOY_ENVIRONMENT: ${{ github.ref == 'refs/heads/master' && 'PRODUCTION' || 'STAGING' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Add SSH key | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ env.SSH_KEY }}" > ~/.ssh/id_rsa | |
chmod 700 ~/.ssh/id_rsa | |
- name: Copy repo to server | |
run: | | |
ssh -o StrictHostKeyChecking=no ${{ env.SSH_USER }}@${{ env.SSH_ADDRESS }} "mkdir -p /home/${{ env.SSH_USER }}/crux" | |
scp -v -o StrictHostKeyChecking=no -r ./* ${{ env.SSH_USER }}@${{ env.SSH_ADDRESS }}:/home/${{ env.SSH_USER }}/crux | |
- name: Move Ben binary | |
run: | | |
ssh -o StrictHostKeyChecking=no ${{ env.SSH_USER }}@${{ env.SSH_ADDRESS }} "sudo mkdir -p /etc/ben/queue; sudo mkdir -p /etc/ben/output; sudo chown -R ${{ env.SSH_USER }}:${{ env.SSH_USER }} /etc/ben; \ | |
if [ -f /etc/ben/ben ]; then \ | |
echo 'Ben binary already exists.'; \ | |
else \ | |
sudo mv /home/${{ env.SSH_USER }}/crux/bin/ben /etc/ben/ben; \ | |
fi" | |
- name: Install apt dependencies | |
run: | | |
sudo apt-get update | |
sudo apt install python3-openstackclient jq pssh awscli -y | |
- name: Clean up SSH key | |
run: | | |
rm -f ~/.ssh/id_rsa |