Skip to content
This repository has been archived by the owner on Sep 9, 2023. It is now read-only.

Commit

Permalink
ci: add GH action to build and publish docker image
Browse files Browse the repository at this point in the history
- Add GH action for build and publish the app docker image
  • Loading branch information
Theodore Georgomanolis authored and theodore86 committed Oct 4, 2022
1 parent cd8eec5 commit cda11aa
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Publish

on:
push:
branches:
- 'main'
paths:
- 'Dockerfile'
- '**.py'
- 'requirements.txt'
- '.github/workflows/build-publish.yml'

jobs:
build_and_publish_docker_image:
runs-on: ubuntu-latest
env:
DOCKERHUB_REPO: 'theodore86/aws-route53'
steps:
- name: 'Checkout SCM'
uses: 'actions/[email protected]'

- name: 'Login to docker registry'
uses: 'docker/[email protected]'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
logout: true

- name: 'Retrieve latest commit sha as image tag'
id: 'git_short_sha'
run: |
short_sha=$(git log -1 --format=%h)
echo "::set-output name=short_sha::$short_sha"
- name: 'Build and push docker image'
uses: 'docker/[email protected]'
with:
push: true
context: .
file: Dockerfile
no-cache: true
tags: |
${{ env.DOCKERHUB_REPO }}:${{ steps.git_short_sha.outputs.short_sha }}
${{ env.DOCKERHUB_REPO }}:latest

0 comments on commit cda11aa

Please sign in to comment.