Skip to content

Build and Push Docker Images #24

Build and Push Docker Images

Build and Push Docker Images #24

Workflow file for this run

name: Build and Push Docker Images
on:
workflow_dispatch:
inputs:
version:
description: 'Version tag for Docker images'
default: 'latest'
required: true
env:
DOCKERHUB_ORGANIZATION: vleerapp
DOCKERHUB_REPOSITORY: vleerapp/backend
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
GITHUB_IMAGE_NAME: ${{ github.repository_owner }}/backend
GITHUB_REGISTRY: ghcr.io
jobs:
build-and-push:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
password: ${{ env.DOCKERHUB_TOKEN }}
username: ${{ env.DOCKERHUB_USERNAME }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
- name: Build and push to DockerHub and GitHub Packages
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.DOCKERHUB_REPOSITORY }}:${{ github.event.inputs.version }}
${{ env.GITHUB_REGISTRY }}/${{ env.GITHUB_IMAGE_NAME }}:${{ github.event.inputs.version }}