Skip to content

Commit

Permalink
add GitHub workflow to build and publish to Docker Hub
Browse files Browse the repository at this point in the history
  • Loading branch information
spujadas committed Oct 3, 2021
1 parent 4df8a07 commit bb11af8
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/docker-publish-to-dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "Docker: Docker Hub"

on:
push:
tags: [ '*' ]

env:
REGISTRY: docker.io
IMAGE_NAME: sebp/elk

jobs:
build_and_publish:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2


- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=true
prefix=
suffix=
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}, latest

- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: ${{ env.IMAGE_NAME }}

0 comments on commit bb11af8

Please sign in to comment.