Skip to content

Commit

Permalink
Tentando escrever um github flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuslao committed Feb 14, 2024
1 parent 266b256 commit ee54b43
Showing 1 changed file with 9 additions and 31 deletions.
40 changes: 9 additions & 31 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
TAG_NAME: latest

jobs:

Expand All @@ -19,34 +20,11 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker image build --no-cache -t ${{ env.IMAGE_NAME }}:latest .

push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: "{{defaultContext}}"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
run: docker image build --no-cache -t ${{ env.IMAGE_NAME }}:${{ TAG_NAME }} .
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push the Docker image
run: docker image push ${{ env.IMAGE_NAME }}:${{ TAG_NAME }}

0 comments on commit ee54b43

Please sign in to comment.