Skip to content

Commit

Permalink
CI to Docker Hub
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensa committed Nov 25, 2021
1 parent 3fbf672 commit 8f27e76
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI to Docker Hub

# Controls when the workflow will run
on:
# Triggers the workflow on push request events but only for tags vX.X.X
push:
tags:
- "v*.*.*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v2

# Setup Buildx as the builder
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

# Avoid having to re-download docker images and reduces the number of pulls against Docker Hub
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# Use Personal Access Token (PAT) and username to log into Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

# Build and push action
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/ubuntu-tini-x11:latest
labels: maintainer=Ruben Suarez <[email protected]>
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

# Echo the image digest to see what was pushed
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

0 comments on commit 8f27e76

Please sign in to comment.