Skip to content

Commit

Permalink
Started working on github actions (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
Corgam authored May 6, 2024
2 parents 3115384 + 6674025 commit 3c2c272
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 14 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Backend - Tests

on:
pull_request:
branches:
- sprint-release
- main
paths:
- "backend/**"
push:
branches:
- sprint-release
- main
paths:
- "backend/**"

jobs:
linting:
name: Check linting
runs-on: ubuntu-latest

steps:
- name: Echo Linting
run: echo "linting"

tests:
needs: linting
name: Run Tests
runs-on: ubuntu-latest

steps:
- name: Echo Test
run: echo "test"
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build Docker Compose

on:
pull_request:
branches:
- sprint-release
- main
paths:
- "backend/**"
- "frontend/**"
push:
branches:
- sprint-release
- main
paths:
- "backend/**"
- "frontend/**"

jobs:
build:
name: Build the Docker Image
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build Image
run: docker compose build --pull
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: publish_sprint_release
name: Deploy Production Service

on:
push:
branches: ["sprint_release"]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{github.actor}}/building-information-enhancer
branches:
- main

jobs:
publish:
Expand All @@ -17,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- name: Login
run: |
echo ${{secrets.PAT}} | docker login ghcr.io -u ${{github.actor}}--password-stdin
echo ${{secrets.PAT}} | docker login ghcr.io -u ${{github.actor}} --password-stdin
- name: Build and Publish
run: |
docker compose build --pull
Expand All @@ -27,16 +24,16 @@ jobs:

deploy:
needs: publish
name: Deploy Image on Server
name: Deploy Image on the Server
runs-on: ubuntu-latest

steps:
- name: Install SSH keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{secrets.SSH_PRIVATE_KEY}}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{secrets.SSH_HOST}} > ~/.ssh/known_hosts
echo "${{secrets.PROD_ENV_SSH_PRIVATE_KEY}}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{secrets.PROD_ENV_SSH_HOST}} > ~/.ssh/known_hosts
- name: Connect and Pull
run: ssh ${{secrets.SSH_USER}}@${{secrets.SSH_HOST}} "cd ${{secrets.WORK_DIR}} && docker compose pull && docker compose up -d && exit"
run: ssh ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose pull && docker compose up -d && exit"
- name: Cleanup
run: rm -rf ~/.ssh
39 changes: 39 additions & 0 deletions .github/workflows/deploy_test_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy Test Service

on:
push:
branches:
- sprint-release

jobs:
publish:
name: Publish Docker Image
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Login
run: |
echo ${{secrets.PAT}} | docker login ghcr.io -u ${{github.actor}} --password-stdin
- name: Build and Publish
run: |
docker compose build --pull
docker-compose push
- name: Logout
run: docker logout

deploy:
needs: publish
name: Deploy Image on the Server
runs-on: ubuntu-latest

steps:
- name: Install SSH keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{secrets.TEST_ENV_SSH_PRIVATE_KEY}}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{secrets.TEST_ENV_SSH_HOST}} > ~/.ssh/known_hosts
- name: Connect and Pull
run: ssh ${{secrets.TEST_ENV_SSH_USER}}@${{secrets.TEST_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose pull && docker compose up -d && exit"
- name: Cleanup
run: rm -rf ~/.ssh
33 changes: 33 additions & 0 deletions .github/workflows/frontend-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Frontend - Tests

on:
pull_request:
branches:
- sprint-release
- main
paths:
- "frontend/**"
push:
branches:
- sprint-release
- main
paths:
- "frontend/**"

jobs:
linting:
name: Check linting
runs-on: ubuntu-latest

steps:
- name: Echo Linting
run: echo "linting"

tests:
needs: linting
name: Run Tests
runs-on: ubuntu-latest

steps:
- name: Echo Test
run: echo "test"
6 changes: 3 additions & 3 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './App.css'
import "./App.css";

function App() {
return <h1> Building Information Enhancer</h1>;
return <h1> Building Information Enhancer v.2</h1>;
}

export default App
export default App;

0 comments on commit 3c2c272

Please sign in to comment.