Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/backend/deployment and up #60

Merged
merged 44 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4bf2c46
chore: Remove unused Docker Compose configuration and Nginx configura…
waveyboym Jun 12, 2024
039bf50
chore: added env variables
waveyboym Jun 12, 2024
4ae2346
feat: added the "ALL" action
waveyboym Jun 12, 2024
2b39732
chore: Update GitHub Actions workflow for golang linting, testing, an…
waveyboym Jun 12, 2024
d822d1f
chore: Update Docker actions versions for QEMU and Buildx and login
waveyboym Jun 12, 2024
0c85237
chore: Update Docker actions versions and GitHub Actions workflow
waveyboym Jun 12, 2024
3d491db
chore: Update Docker actions versions and GitHub Actions workflow
waveyboym Jun 12, 2024
6961cfe
chore: Update Docker actions versions and GitHub Actions workflow
waveyboym Jun 12, 2024
8296ef0
chore: Pull latest Docker image and update environment variables
waveyboym Jun 12, 2024
b44b026
chore: Update Docker login command to use password from stdin
waveyboym Jun 12, 2024
52a954a
chore: Copy necessary files to VM and update Docker images and enviro…
waveyboym Jun 12, 2024
f344e6e
chore: Update deployment configuration for VM
waveyboym Jun 12, 2024
58f6d01
chore: Update deployment configuration for VM
waveyboym Jun 12, 2024
583e867
chore: Update deployment configuration for VM
waveyboym Jun 12, 2024
4a56dc6
chore: Update GPG passphrase decryption command in deployment workflow
waveyboym Jun 12, 2024
3d4b0e4
chore: Update Docker compose commands in deployment workflow
waveyboym Jun 12, 2024
2d0d425
chore: Update Docker compose commands and deployment configuration fo…
waveyboym Jun 12, 2024
f41ea8d
chore: Update deployment configuration for VM
waveyboym Jun 12, 2024
6e4f3cf
chore: Update deployment configuration for VM and Docker compose comm…
waveyboym Jun 12, 2024
1eff5af
chore: Update GPG passphrase decryption command in deployment workflow
waveyboym Jun 12, 2024
8003e35
chore: Update deployment workflow for building and pushing Docker image
waveyboym Jun 12, 2024
82ed786
chore: Update deployment workflow and Docker compose configuration fo…
waveyboym Jun 12, 2024
74cbfe0
chore: Update deployment workflow and Docker compose configuration fo…
waveyboym Jun 12, 2024
d42f0b9
chore: Update Docker image tag in docker-compose.dev.yml
waveyboym Jun 12, 2024
f776ec6
chore: Remove unnecessary line in deployment workflow
waveyboym Jun 12, 2024
c96bee6
chore: Update deployment workflow to include SSH step for VM
waveyboym Jun 12, 2024
32c50e0
chore: Update deployment workflow and Docker compose configuration fo…
waveyboym Jun 12, 2024
d4286fc
chore: Update Docker image tag in docker-compose.dev.yml
waveyboym Jun 12, 2024
1e53c6b
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 12, 2024
d7faa4d
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 12, 2024
a789f4f
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 12, 2024
3fe179d
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 12, 2024
9226321
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 12, 2024
833498e
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 12, 2024
8e5333d
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 12, 2024
e4b0a44
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 12, 2024
0dff42d
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 12, 2024
004d0c4
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 13, 2024
96faf1f
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 13, 2024
5244476
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 14, 2024
09f795b
Update certificate and key file paths in main.go and config.go
waveyboym Jun 14, 2024
5f64e39
Update certificate and key file paths in main.go and config.go
waveyboym Jun 16, 2024
01e28bd
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 16, 2024
68eb0f0
chore: Update Docker image tag and file path in deploy-golang-develop…
waveyboym Jun 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Build and Release all

on:
push:
branches:
- action-needs-refinement-lol

jobs:
build-backend-binary:
name: Build Backend Binary for Windows, Linux and MacOS
runs-on: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.16'

- name: Build Backend Binary
run: |
go build -o occupi-backend ./occupi-backend/cmd/main.go


build-expo-app:
name: Build Expo App
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install Expo CLI
run: |
npm install -g expo-cli

- name: Install Expo dependencies
run: |
cd occupi-frontend
npm install

- name: Build Expo App
run: |
cd occupi-frontend
expo build:web


build-vite-app:
name: Build Vite App
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install Vite
run: |
npm install -g create-vite

- name: Install Vite dependencies
run: |
cd occupi-frontend
npm install

- name: Build Vite App
run: |
cd occupi-frontend
npm run build

build-tauri-app:
name: Build Tauri App
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Rust
uses: actions/setup-rust@v1
with:
rust-version: '1.53.0'

- name: Install Tauri
run: |
cargo install tauri-bundler --force

- name: Build Tauri App
run: |
cd occupi-frontend
tauri build

release:
name: Release
runs-on: ubuntu-latest
needs: [build-backend-binary, build-expo-app, build-vite-app, build-tauri-app]
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install GitHub CLI
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install gh

- name: Login to GitHub
run: |
gh auth login

- name: Create a Release
run: |
gh release create v1.0.0 -t "v1.0.0" -n "v1.0.0" ./occupi-backend/occupi-backend ./occupi-frontend/occupi-frontend ./occupi-frontend/dist ./occupi-frontend/build ./occupi-frontend/target/release/occupi-frontend

- name: Upload Release Assets
run: |
gh release upload v1.0.0 ./occupi-backend/occupi-backend ./occupi-frontend/occupi-frontend ./occupi-frontend/dist ./occupi-frontend/build ./occupi-frontend/target/release/occupi-frontend
150 changes: 150 additions & 0 deletions .github/workflows/deploy-golang-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Lint, Test, Build and Deploy Dev golang

on:
push:
branches: ["develop"]
paths: [
"occupi-backend/cmd/**",
"occupi-backend/configs/**",
"occupi-backend/pkg/**",
"occupi-backend/.golangci.yml",
"occupi-backend/.dev.env.gpg",
"occupi-backend/tests/**",
".github/workflows/deploy-golang-develop.yml"
]

workflow_dispatch:

defaults:
run:
working-directory: occupi-backend

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21' # Specify the Go version you are using

- name: Install golangci-lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

- name: Run golangci-lint
run: |
golangci-lint run

test:
needs: lint
name: Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21' # Specify the Go version you are using

- name: Run tests
run: |
go test -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/handlers ./tests/... -coverprofile=coverage.out

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}

build-test:
needs: test
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21' # Specify the Go version you are using

- name: Build the code
run: |
go build -v cmd/occupi-backend/main.go

build-push-docker:
name: Build and Push Develop Docker Image
runs-on: ubuntu-latest
needs: build-test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Decrypt env variables
run: |
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --quiet --batch --yes --decrypt --passphrase-fd 0 .dev.env.gpg > .dev.env

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: occupi-backend
file: occupi-backend/Dockerfile.dev
platforms: linux/amd64,linux/arm64
push: true
no-cache: true
tags: ${{ secrets.DOCKER_USERNAME }}/occupi-backend:latest-develop

deploy:
name: Deploy for Develop
runs-on: ubuntu-latest
needs: build-push-docker

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Copy files to VM
uses: appleboy/[email protected]
with:
host: ${{ secrets.VM_IP }}
username: ${{ secrets.VM_USERNAME }}
key: ${{ secrets.VM_SSH_KEY }}
source: "occupi-backend/docker-compose.dev.yml,occupi-backend/Dockerfile.dev"
target: "/home/${{ secrets.VM_USERNAME }}/occupi-backend-dev"

# SSH to VM and run commands
- name: SSH to VM
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VM_IP }}
username: ${{ secrets.VM_USERNAME }}
key: ${{ secrets.VM_SSH_KEY }}
script: |
cd /home/${{ secrets.VM_USERNAME }}/occupi-backend-dev/occupi-backend
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }} docker compose -f docker-compose.dev.yml down
DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }} docker compose -f docker-compose.dev.yml pull
DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }} docker compose -f docker-compose.dev.yml up -d
Loading
Loading