Skip to content

Commit

Permalink
Login dockerhub before pulling images
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Góes <[email protected]>
  • Loading branch information
tiagodread committed Aug 15, 2024
1 parent 7379792 commit 627d816
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,18 @@ env:
SHA: ${{ github.sha }}

jobs:
build-docker-image:
run-api-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push todo-api
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/todo-api:${{ env.SHA }}

- name: Build and push todo-db
uses: docker/build-push-action@v6
with:
file: Dockerfile.db
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/todo-db:${{ env.SHA }}

api-tests:
runs-on: ubuntu-latest
needs: build-docker-image
steps:
- uses: actions/checkout@v4

- name: Start containers
uses: hoverkraft-tech/[email protected]
env:
SHA: ${{ env.SHA }}

- name: Run API tests
run: |
docker-compose up -d
max_attempts=3
attempt=1
Expand All @@ -65,3 +41,30 @@ jobs:
- name: Test
run: go test -v ./...

build-push-docker-image:
runs-on: ubuntu-latest
needs: run-api-tests
steps:
- uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push todo-api
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/todo-api:${{ env.SHA }}

- name: Build and push todo-db
uses: docker/build-push-action@v6
with:
file: Dockerfile.db
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/todo-db:${{ env.SHA }}


0 comments on commit 627d816

Please sign in to comment.