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
name: BogoSort_2024_2 Deploy | |
on: | |
push: | |
branches: [main, develop, 'TP-*'] | |
pull_request: | |
branches: [main] | |
jobs: | |
run-linters: | |
name: run-linters | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
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: /path/to/your/cache | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} | |
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: 20 | |
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: /path/to/your/cache | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Get Dependencies | |
run: go get ./... | |
- name: Build Application | |
run: go build ./... | |
- name: Run Tests | |
run: | | |
go test -json ./... -coverprofile coverprofile_.tmp -coverpkg=./... ; \ | |
grep -v -e '/mocks' -e 'mock_repository.go' -e 'mock.go' -e 'docs.go' -e '_easyjson.go' -e '.pb.go' -e 'gen.go' -e '/cmd/' -e '/config/' -e '/pkg/connector/' coverprofile_.tmp > coverprofile.tmp ; \ | |
rm coverprofile_.tmp ; \ | |
go tool cover -html coverprofile.tmp -o ../heatmap.html; \ | |
go tool cover -func coverprofile.tmp | |
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: 20 | |
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 |