Skip to content

Commit

Permalink
Add workflow and push image
Browse files Browse the repository at this point in the history
  • Loading branch information
tiendat1011 committed Jun 22, 2024
1 parent b5e8ed5 commit d1d9e0b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/create-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Push Docker Image

on:
push:
branches:
- main

jobs:
build:
name: "Build and push image"
env:
DOCKER_USER: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
ENV_FILE_CONTENT: ${{secrets.ENV_FILE_CONTENT}}

runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

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

- name: Create .env file
run: echo "${{ env.ENV_FILE_CONTENT }}" > .env

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

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: tiendat1011/DACN-Backend:latest
file: ./Dockerfile
build-args:
ENV_FILE: .env

0 comments on commit d1d9e0b

Please sign in to comment.