Skip to content

Commit

Permalink
Add action for publishing Docker image builds
Browse files Browse the repository at this point in the history
  • Loading branch information
dabico committed Feb 21, 2024
1 parent 2d94931 commit 9d6a7a0
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Publish image builds to Docker Hub'
on:
push:
tags: [ 'v*' ]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout latest
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: seart
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: meta
name: Extract metadata for Docker
uses: actions/github-script@v7
with:
script: |
const patch = context.ref.substring(11)
const parts = patch.split('.')
const minor = `${parts[0]}.${parts[1]}`
const major = parts[0]
core.setOutput('tag-patch', patch)
core.setOutput('tag-minor', minor)
core.setOutput('tag-major', major)
- name: Build and push image
uses: docker/build-push-action@v5
with:
push: true
tags: |
seart/${{ context.repo.repo }}:latest
seart/${{ context.repo.repo }}:${{ steps.meta.outputs.tag-major }}
seart/${{ context.repo.repo }}:${{ steps.meta.outputs.tag-minor }}
seart/${{ context.repo.repo }}:${{ steps.meta.outputs.tag-patch }}

0 comments on commit 9d6a7a0

Please sign in to comment.