Delete .github/workflows/github-actions-demo.yml #2
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: Go Backend CI/CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Build Test Docker Image | |
run: docker build -t jokil/esefexapi:test -f Dockerfile.test . | |
- name: Run Tests in Docker Container | |
run: doocker run jokil/esefexapi:test go test ./... | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Build Prod Docker Image | |
run: docker build -t jokil/esefexapi:latest -f Dockerfile . | |
- name: Login to Docker Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push Docker Image | |
- run: docker push jokil/esefexapi:latest | |
- name: Deploy to Production | |
run: | | |
# SSH into your production server | |
ssh [email protected] "cd /api && \ | |
docker-compose down && \ | |
docker-compose pull && \ | |
docker-compose up -d" |