Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
    • Helm Chart
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log & Monitor
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
  • Toggle search form

[Github-Action] Let’s use GitHub Action to build and push the docker image to the docker hub.

Posted on December 21, 2022December 21, 2022 By nim No Comments on [Github-Action] Let’s use GitHub Action to build and push the docker image to the docker hub.

Hello các bạn!
Hôm nay chúng ta sẽ cùng nhau sử dụng github action để build và push image to dockerhub.
Mình thực hiện demo trên repo này: https://github.com/mrnim94/doctor-doom

Contents

  • 1) Create Access Token on Docker hub
  • 2) Using Github Action

1) Create Access Token on Docker hub

Sau đó bạn tạo 1 repository trên dockerhub

2) Using Github Action

Để github action có thể login vào docker hub, bạn cần tạo các secrets bằng cách bên dưới

Bạn tạo folder: .github/workflows và trong folder có file: main.yml

name: ci

on:
  push:
    branches:
      - "master"
    tags:
      - '*.*.*'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v3
      -
        name: Set env
        run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
      -
        name: Login to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_HUB_USERNAME }}
          password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      -
        name: Build and push
        uses: docker/build-push-action@v3
        with:
          context: .
          file: ./Dockerfile
          push: true
          tags: ${{ secrets.DOCKER_HUB_USERNAME }}/doctor-doom:latest, ${{ secrets.DOCKER_HUB_USERNAME }}/doctor-doom:${{ env.RELEASE_VERSION }}

Ở đây thì mình mong muốn là nó sẽ build 1 image latest và image có tag là RELEASE_VERSION

Đây là hình ảnh gihub action build
đây là image trên docker được push bới github action.

https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions

AWS - Amazon Web Service

Post navigation

Previous Post: Wins from Effective Kafka Monitoring at Adobe: Stability, Performance, and Cost Savings
Next Post: Conventional Commits

More Related Articles

[Terraform] Solve “Redundant ignore_changes element” on EKSmodule AWS - Amazon Web Service
[Redis] ElastiCache-Redis Cross-Region Replication|Global DataStore AWS - Amazon Web Service
[Kafka/MSK] Install kafka or MSK on aws through terraform. AWS - Amazon Web Service
[VPC] The difference between public and private subnets in Amazon VPC? AWS - Amazon Web Service
[Terraform] – Terraform Beginner – Lesson 7: Terraform Modules AWS - Amazon Web Service
[Terraform] – Terraform Beginner – Lesson 9: Terraform with AWS – part 2 AWS - Amazon Web Service

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [Smartctl] Instruction check the health disk of Raspberry. January 16, 2023
  • [kubectl/Argocd] How to create a kubectl config file for serviceaccount or from the cluster secret of Argocd January 12, 2023
  • [Helm/Github] Create a public Helm chart repository with GitHub Pages January 8, 2023
  • [AWS] How to increase the disk size of a Windows EC2 machine? January 4, 2023
  • [Redis] ElastiCache-Redis Cross-Region Replication|Global DataStore January 3, 2023

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • Golang
    • Jquery & JavaScript
    • Laravel
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kubernetes
      • Ingress
    • Longhorn – Storage
    • Vault
    • VictoriaMetrics
  • Log & Monitor
    • ELK
      • Kibana
      • Logstash
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2023 NimTechnology.