Skip to content

Commit

Permalink
Merge pull request #19 from ellitedev/dev
Browse files Browse the repository at this point in the history
Update docker-hub.yml
  • Loading branch information
ellitedev committed Sep 13, 2023
2 parents 150725e + aa1abaf commit e4bfe13
Showing 1 changed file with 16 additions and 41 deletions.
57 changes: 16 additions & 41 deletions .github/workflows/docker-hub.yml
@@ -1,57 +1,32 @@
name: Build and Push Docker Image to Docker Hub
name: Build and Push Docker Image

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
branches:
- master

jobs:
build:
build-and-push:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker-compose build --no-cache --force-rm
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Test the Docker image
run: docker-compose up -d
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: Checkout code
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
- name: Login to Docker Hub
uses: docker/login-action@v1
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.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build Docker image
run: docker build -t ${{ github.repository }} .

- name: Tag Docker image
run: docker tag ${{ github.repository }} ${{ secrets.DOCKER_USERNAME }}/${{ github.repository }}:latest

- name: Build and push Docker image
- name: Push Docker image
uses: docker/build-push-action@v2
with:
context: "{{defaultContext}}"
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.repository }}:latest

0 comments on commit e4bfe13

Please sign in to comment.