Skip to content

Docker Image Build and Push #20

Docker Image Build and Push

Docker Image Build and Push #20

Workflow file for this run

name: Docker Image CI
on:
# push:
# branches: [ "master" ]
# pull_request:
# branches: [ "master" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check parameter
run: echo "Date " $(date +%Y%m%d) \\
echo "Image " ${{ vars.DOCKERHUB_IMAGE_NAME }} \\
docker buildx build --help
- name: Build the Docker image
run: docker build --file Dockerfile \\
--platform linux/amd64,linux/arm64 \\
--sbom=true \\
--tag ${{ vars.DOCKERHUB_IMAGE_NAME }}:$(date +%Y%m%d) .
- name: Push the Docker image
run: docker push ${{ vars.DOCKERHUB_IMAGE_NAME }}:$(date +%Y%m%d)
- name: Push the Docker image with latest tag
run: docker tag ${{ vars.DOCKERHUB_IMAGE_NAME }}:$(date +%Y%m%d) ${{ vars.DOCKERHUB_IMAGE_NAME }}:latest && docker push ${{ vars.DOCKERHUB_IMAGE_NAME }}:latest