Merge pull request #1 from RagoDevs/dependabot/go_modules/golang.org/… #26
This file contains hidden or 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: Go Test, Build and Deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v3 | |
| with: | |
| go-version: 1.23.4 | |
| - name: Test | |
| run: go test -v ./... | |
| - name: Build Static Binary | |
| run: | | |
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o mailer ./ | |
| file mailer | |
| ldd mailer || echo "Static binary - no dependencies" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: mailer-artifact | |
| path: ./mailer | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: mailer-artifact | |
| - name: Deploy to server | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: ${{ secrets.USERNAME }} | |
| password: ${{ secrets.PASSWORD }} | |
| port: ${{ secrets.PORT }} | |
| source: ./mailer | |
| target: "/home/${{ secrets.USERNAME }}/projects/mailer" | |
| - name: Start Mail Server service | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: ${{ secrets.USERNAME }} | |
| password: ${{ secrets.PASSWORD }} | |
| port: ${{ secrets.PORT }} | |
| script: | | |
| cd /home/${{ secrets.USERNAME }}/projects/mailer | |
| chmod +x mailer | |
| echo ${{ secrets.PASSWORD }} | sudo -S systemctl stop mailer.service | |
| echo ${{ secrets.PASSWORD }} | sudo -S systemctl start mailer.service |