Skip to content

updated: deploy

updated: deploy #10

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
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Print Current Directory
run: pwd
- name: List Files
run: ls -R
- name: Check for .golangci.yaml
run: |
if [ -f .golangci.yaml ]; then
echo ".golangci.yaml found"
else
echo ".golangci.yaml not found"
exit 1
fi
- name: List Files in Working Directory
run: ls -la
- name: Clear Cache
run: |
rm -rf ~/.cache/go-build
rm -rf ~/go/pkg/mod
- name: Install Dependencies
run: go mod tidy
- name: Run Linters
uses: golangci/golangci-lint-action@v3
with:
version: v1.56.2
args: --config .golangci.yaml --verbose
working-directory: .
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
run-tests:
name: Run Tests
needs: run-linters
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- 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'
needs: [run-linters, run-tests]
runs-on: ubuntu-latest
steps:
- name: Deploy to Server
uses: appleboy/ssh-action@v0.1.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
cd /home/${{ secrets.USERNAME }}/server/back
git checkout develop
git fetch && git pull
sudo docker-compose build
sudo docker-compose down
sudo docker-compose up -d --build --remove-orphans