Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
box

GitHub Action

The Docker CLI

v1.0.2

The Docker CLI

box

The Docker CLI

GitHub Action with docker cli

Installation

Copy and paste the following snippet into your .yml file.

              

- name: The Docker CLI

uses: actions-hub/[email protected]

Learn more about this action in actions-hub/docker

Choose a version

docker

Docker

GitHub Action with docker cli.

Usage

- name: Login to docker hub
  uses: actions-hub/docker/login@master
  env:
    DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
    DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

- name: Build :latest
  run: docker build -t ${GITHUB_REPOSITORY}:latest .

- name: Push to docker hub :latest
  uses: actions-hub/docker@master
  with:
    args: push ${GITHUB_REPOSITORY}:latest

Actions

This repository contains 2 actions:

Example

Latest

name: Docker registry

on: [push]

jobs:
  github:
    runs-on: ubuntu-latest    
    steps:
      - uses: actions/checkout@v1

      - name: Login to github registry
        uses: actions-hub/docker/login@master
        env:
          DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
          DOCKER_REGISTRY_URL: docker.pkg.github.com

      - name: Build :latest
        if: success()
        run: docker build -t docker.pkg.github.com/${{ github.repository }}/app:latest .
        
      - name: Push to docker hub :latest
        if: success()
        uses: actions-hub/docker@master
        with:
          args: push docker.pkg.github.com/${{ github.repository }}:latest

Tag

name: Docker registry

on: 
   push:
     tags:
       - 'v*'

jobs:
  github:
    runs-on: ubuntu-latest    
    steps:
      - uses: actions/checkout@v1

      - name: Login to github registry
        uses: actions-hub/docker/login@master
        env:
          DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
          DOCKER_REGISTRY_URL: docker.pkg.github.com

      - name: Build :tag
        if: success()
        run: docker build -t docker.pkg.github.com/${{ github.repository }}/app:${IMAGE_TAG} .

      - name: Push to docker hub :tag
        if: success()
        uses: actions-hub/docker@master
        with:
          args: push docker.pkg.github.com/${{ github.repository }}:${IMAGE_TAG}

Universal

name: Deploy to docker hub

on:
   push:
     branches:    
      - master
     tags:
       - 'v*'

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@master

      - name: Login to docker hub
        if: success()
        uses: actions-hub/docker/login@master
        env:
          DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

      - name: Build image
        if: success()
        run: docker build -t ${GITHUB_REPOSITORY}:${IMAGE_TAG} .

      - name: Push to docker registry
        if: success()
        uses: actions-hub/docker@master
        with:
          args: push ${GITHUB_REPOSITORY}:${IMAGE_TAG}

Licence

MIT License