ci-cd and linter #76
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: CI | |
on: | |
push: | |
branches: | |
- dev | |
- main | |
jobs: | |
lint: | |
name: Linters | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21.x' | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
test: | |
name: Tests | |
runs-on: ubuntu-latest | |
needs: lint | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21.x' | |
- name: Build | |
run: make build_ | |
- name: Test | |
run: make test | |
deploy: | |
name: Deploy App | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.ref == 'refs/heads/dev' | |
steps: | |
- name: Pull code | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: cd /home/${{ secrets.USERNAME }}/2024_1_TeaStealers/ && git pull | |
- name: Build containers | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: cd /home/${{ secrets.USERNAME }}/2024_1_TeaStealers/ && docker compose build | |
- name: Restart service | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: cd /home/${{ secrets.USERNAME }}/2024_1_TeaStealers/ && docker compose down && docker compose up -d | |
- name: Make migrate | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: cd /home/${{ secrets.USERNAME }}/2024_1_TeaStealers/ && make migrate-up |