Skip to content

updated deploy

updated deploy #93

Workflow file for this run

name: BogoSort_2024_2 Deploy
on:
push:
branches: [main, develop, 'TP-*']
pull_request:
branches: [main, develop, 'TP-*']
jobs:
run-linters:
name: run-linters
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out code into directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: 1.23
id: go
- name: Cache Go modules
uses: actions/cache@v2
with:
path: /tmp/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install required dependencies
run: go mod tidy
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: latest
working-directory: .
args: -c ./.golangci.yaml
run-tests:
name: run-tests
needs: run-linters
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Cache Go modules
uses: actions/cache@v2
with:
path: /tmp/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get Dependencies
run: go get ./...
- name: Build Application
run: go build ./...
- name: Run Tests
run: go test ./... -v
deploy:
name: Deploy to Server
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
needs: [run-linters, run-tests]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Deploy to Server
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
debug: true
script: |
cd /home/${{ secrets.USERNAME }}/2024_2_BogoSort
git checkout develop
git fetch && git pull
sudo docker-compose build
sudo docker-compose down
sudo docker-compose up -d --build --remove-orphans