Skip to content

Commit

Permalink
main-cd Docker Hub image push
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimowiczm committed Jan 1, 2024
1 parent 96b73d7 commit 6fdd968
Showing 1 changed file with 42 additions and 13 deletions.
55 changes: 42 additions & 13 deletions .github/workflows/main-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,64 @@ name: Push image on Azure repository
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:

env:
IMAGE_NAME: codendui
IMAGE_REGISTRY: maksimowiczm
DOCKERFILE: ./Dockerfile
IMAGE_NAME: ${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }}/codend/frontend:latest

jobs:
push-release-image:
push-release-image-azure:
name: Push image on Azure registry
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Azure registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
password: ${{ secrets.AZURE_REGISTRY_TOKEN }}

- name: Docker build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
push: true
context: .
file: ${{ env.DOCKERFILE }}
target: production
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.IMAGE_NAME }}
tags: |
${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }}/${{ secrets.AZURE_REGISTRY_NAME }}/${{ env.IMAGE_NAME }}
push-release-image-dockerhub:
name: Push image on Docker Hub registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to Docker Hub registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_HUB_REGISTRY_TOKEN }}

- name: Docker build
uses: docker/build-push-action@v5
with:
push: true
context: .
file: ${{ env.DOCKERFILE }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: production
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 6fdd968

Please sign in to comment.