Add renovate.json #6
Workflow file for this run
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
on: [push, pull_request] | |
name: Continuous Integration and Deployment | |
jobs: | |
test-nocache: | |
strategy: | |
matrix: | |
go-version: [1.21.x] | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
cache: false | |
- run: go test ./... | |
test-cache: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 1.21.x | |
- run: go test ./... | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [test-nocache, test-cache] # Ensure deployment occurs only after tests pass | |
if: github.ref == 'refs/heads/master' # Deploy only for master branch | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GIT_TOKEN }} | |
- name: Build and push Docker image | |
run: | | |
docker build . --tag ghcr.io/tuanha1305/go-sock5-server/app-sock5:${{ github.sha }} | |
docker push ghcr.io/tuanha1305/go-sock5-server/app-sock5:${{ github.sha }} | |
- name: Deploy to Production Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.IP_SERVER_PRO }} | |
username: ${{ secrets.USER_SSH }} | |
key: ${{ secrets.SSH_KEY_PRO }} | |
script: | | |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
docker pull ghcr.io/tuanha1305/go-sock5-server/app-sock5:${{ github.sha }} | |
docker stop sock5-app || true | |
docker rm sock5-app || true | |
docker run -d --name sock5-app -p 8080:8080 ghcr.io/tuanha1305/go-sock5-server/app-sock5:${{ github.sha }} |