Skip to content

Commit

Permalink
chore: Add Docker Hub and GitHub Container Registry image publishing …
Browse files Browse the repository at this point in the history
…workflow
  • Loading branch information
sofia-assis committed May 10, 2024
1 parent 2251314 commit d48ed4a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/publish-website-monitor-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Template for Docker Image Push to Docker Hub
on:
push:
branches: [ "main", "dev"]
workflow_dispatch: # allow user to specify which
inputs:
environment:
description: 'Target environment'
required: true
default: 'dev' # default value if not provided


jobs:
push_to_registry:
name: Push Docker Image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Build version
id: date
run: echo "{name}=date::$(date +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: |
ninjaasa/template-python-project
ghcr.io/${{ github.repository }}
# tag image to be latest if pushing to main branch, dev if pushing to dev branch
tags: |
type=raw,value=${{github.run_id}}
type=raw,value=${{ github.ref == 'refs/heads/main' && 'latest' || 'dev' }}
labels: |
org.label-schema.build-date=${{ steps.date.outputs.date}}
org.opencontainers.image.created=${{ steps.date.outputs.date}}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

7 changes: 7 additions & 0 deletions app/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from placeholder import placeholder

def main():
print(placeholder())

if __name__ == '__main__':
main()

0 comments on commit d48ed4a

Please sign in to comment.