Skip to content

feat(ci/cd): build backend-migrations image during docker-publish.yml… #4

feat(ci/cd): build backend-migrations image during docker-publish.yml…

feat(ci/cd): build backend-migrations image during docker-publish.yml… #4

name: Build and Push Docker Image
on:
push:
branches:
- main
workflow_dispatch:
env:
IMAGE_NAME: ${{ vars.DOCKERHUB_USERNAME }}/backend
MIGRATIONS_IMAGE_NAME: ${{ vars.DOCKERHUB_USERNAME }}/backend-migrations
permissions:
contents: read
jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Log in to Docker Hub
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Main backend image
- name: Extract metadata for backend
id: meta-backend
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051
with:
images: docker.io/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=,format=short
- name: Build and push backend image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta-backend.outputs.tags }}
labels: ${{ steps.meta-backend.outputs.labels }}
provenance: false
# Migrations image
- name: Extract metadata for migrations
id: meta-migrations
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051
with:
images: docker.io/${{ env.MIGRATIONS_IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=,format=short
- name: Build and push migrations image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
with:
context: .
file: ./Dockerfile.migrations
push: true
tags: ${{ steps.meta-migrations.outputs.tags }}
labels: ${{ steps.meta-migrations.outputs.labels }}
provenance: false