Merge pull request #59 from zbyju/dev #35
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
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
run_cicd: | |
name: run pull | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20" | |
- name: Install npm dependencies for Web App | |
working-directory: apps/web | |
run: npm install | |
- name: Run Tests for Web App | |
working-directory: apps/web | |
run: npm run test | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: "1.22" | |
- name: Run Tests for Snapshot Handler | |
working-directory: apps/snapshot-handler | |
run: go test ./... | |
- name: Run Tests for Babybox Service | |
working-directory: apps/babybox-service | |
run: go test ./... | |
- name: Install SSH Keys | |
# check this thread to understand why its needed: | |
# https://stackoverflow.com/a/70447517 | |
run: | | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
install -m 600 -D /dev/null ~/.ssh/id_rsa | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
ssh-keyscan -p ${{secrets.SSH_PORT }} -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts | |
chmod 644 ~/.ssh/known_hosts | |
- name: Connect and Pull | |
run: ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && git checkout ${{ secrets.MAIN_BRANCH }} && git pull && docker compose up --detach --build --force-recreate && exit" | |
- name: Cleanup | |
run: rm -rf ~/.ssh |