fix deploy section in deploy_dockerhub.yml #2
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: Tests and deploy to DockerHub | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| # Run tests and show coverage | |
| run_tests: | |
| strategy: | |
| matrix: | |
| go-version: [1.23.x] | |
| os: [ubuntu-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Install Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Setup environments | |
| env: | |
| HTTP_PORT: ${{ secrets.HTTP_PORT}} | |
| DB_FILENAME: ${{ secrets.DB_FILENAME }} | |
| run: | | |
| echo "HTTP_PORT=$HTTP_PORT" >> .env | |
| echo "DB_FILENAME=$DB_FILENAME" >> .env | |
| - name: Check go mod | |
| run: go mod tidy | |
| - name: Run tests and show coverage | |
| run: go test -v -race -cover -count=1 ./... | |
| # Deploy to DockerHub | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: run_tests | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v3 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v1 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Push to Docker Registry | |
| id: docker_build | |
| uses: docker/build-push-action@v2 | |
| with: | |
| push: true | |
| tags: iqhater/greeter_api:latest |