Coder Social home page Coder Social logo

dockerhub-build-push's Introduction

Dockerhub-Build-Push

Introduction

The GitHub Action is used to build Docker images and upload them to docker hub.

Example of Workflow

Create the following yml file, with any file name, using the configuration reference as follows: .github/workflows/xxxx.yml :

name: Docker Build And Push To Docker Hub

on:
  push:
    branches:
      - master

jobs:
  build:
    name: Build Spring Boot
    runs-on: ubuntu-latest
    steps:
      - name: Git Checkout Code
        uses: actions/checkout@v1
        id: git_checkout

      - name: Set up JDK 12.0
        uses: actions/setup-java@v1
        with:
          java-version: 12.0

      - name: Build with Gradle
        run: ./gradlew build

      - name: Build Docker Image
        id: buildAndPushImage
        uses: abhishek-070/[email protected]
        with:
          registry_url: 'docker.io'
          repository_name: 'demo-app'
          user_name: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
          image_version: 'v1.0'
          docker_file: '.'
      - name: Get pre step result output image_pull_url
        run: echo "The time was ${{ steps.buildAndPushImage.outputs.image_pull_url }}"

Set registry_url、repository_name、user_name、password for uploading image to docker hub. For username and password set github secrets so that credentials are not exposed. You can use ${{ secrets.DOCKERHUB_USERNAME }} ${{ secrets.DOCKERHUB_TOKEN }} as github secret keys。 For docker hub password generate access token. Ref. Settings

Description

The following parameters can be found in the docker hub documentation

Parameter Required Description
registry_url Yes Docker hub registry,eg: docker.io
repository_name Yes Docker hub target repository name
user_name Yes Docker hub username
password Yes Docker hub access token
image_version Yes Docker image tag
docker_file No Context directory, default is(.)

Output parameters

After the script is executed, use following parameter for docker pull.

Parameter Description
image_pull_url The pull address returned after the successful upload of the image, eg: Use example: docker.io/abhishek-070/demo-app:v1.0 command: docker pull ${{ steps.<steps.id>.outputs.image_pull_url }}

dockerhub-build-push's People

Contributors

abhishek-070 avatar saxmihirverma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.