Skip to content

Commit

Permalink
fix: Container issue fix for multiple branch (#1539)
Browse files Browse the repository at this point in the history
  • Loading branch information
AjitPadhi-Microsoft authored Nov 27, 2024
1 parent 8df387a commit e4dd5f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/build-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ on:
workflow_run:
workflows: [Tests]
types: [completed]
branches:
- main
- dev
- demo
branches: [main, dev, demo]
pull_request:
branches:
- main
- dev
- demo
branches: [main, dev, demo]
types:
- opened
- ready_for_review
Expand All @@ -38,5 +32,6 @@ jobs:
username: ${{ github.event.workflow_run.head_branch == 'main' && 'fruoccopublic' || 'cwydcontainerreg'}}
app_name: ${{ matrix.app_name }}
dockerfile: ${{ matrix.dockerfile }}
push: ${{ github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'dev' || github.event.workflow_run.head_branch == 'demo' }}
branch: ${{ github.event.workflow_run.head_branch }}
push: ${{ github.event_name == 'workflow_run' && (github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'dev' || github.event.workflow_run.head_branch == 'demo') }}
secrets: inherit
11 changes: 7 additions & 4 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ on:
dockerfile:
required: true
type: string
branch:
required: false
type: string
push:
required: true
type: boolean
Expand All @@ -33,15 +36,15 @@ jobs:
uses: actions/checkout@v4

- name: Docker Login
if: ${{ inputs.push == true && github.ref_name == 'main' }}
if: ${{ inputs.push == true && inputs.branch == 'main' }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Dev Docker Login
if: ${{ inputs.push == true && (github.ref_name == 'dev' || github.ref_name == 'demo') }}
if: ${{ inputs.push == true && (inputs.branch == 'dev' || inputs.branch == 'demo') }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
Expand All @@ -61,7 +64,7 @@ jobs:
context: .
file: ${{ inputs.dockerfile }}
push: ${{ inputs.push }}
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || 'latest' }}
cache-from: type=registry,ref=${{ inputs.registry }}/${{ inputs.app_name}}:${{ inputs.branch == 'main' && 'latest' || inputs.branch == 'dev' && 'dev' || inputs.branch == 'demo' && 'demo' || 'latest' }}
tags: |
${{ inputs.registry }}/${{ inputs.app_name}}:${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || 'latest' }}
${{ inputs.registry }}/${{ inputs.app_name}}:${{ inputs.branch == 'main' && 'latest' || inputs.branch == 'dev' && 'dev' || inputs.branch == 'demo' && 'demo' || 'latest' }}
${{ inputs.registry }}/${{ inputs.app_name}}:${{ steps.date.outputs.date }}_${{ github.run_number }}

0 comments on commit e4dd5f2

Please sign in to comment.