fix: Dockerfile issue #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Docker Image | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
- demo | |
pull_request: | |
types: | |
- opened | |
- ready_for_review | |
- reopened | |
- synchronize | |
branches: | |
- main | |
- dev | |
- demo | |
workflow_dispatch: | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to Azure Container Registry | |
if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix') }} | |
uses: azure/docker-login@v2 | |
with: | |
login-server: ${{ secrets.ACR_LOGIN_SERVER }} | |
username: ${{ secrets.ACR_USERNAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Determine Tag Name Based on Branch | |
id: determine_tag | |
run: echo "tagname=${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || github.head_ref || 'default' }}" >> $GITHUB_OUTPUT | |
- name: Build Docker Image and optionally push | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./App | |
file: ./App/WebApp.Dockerfile | |
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' }} | |
tags: | | |
${{ secrets.ACR_LOGIN_SERVER }}/km-app:${{ steps.determine_tag.outputs.tagname }} | |
${{ secrets.ACR_LOGIN_SERVER }}/km-app:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} | |
- name: Build and Push Docker Image for km-rag-function | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./AzureFunctions/km-rag-function | |
file: ./AzureFunctions/km-rag-function/Dockerfile | |
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' }} | |
tags: | | |
${{ secrets.ACR_LOGIN_SERVER }}/km-rag-function:${{ steps.determine_tag.outputs.tagname }} | |
${{ secrets.ACR_LOGIN_SERVER }}/km-rag-function:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} | |
- name: Build and Push Docker Image for km-charts-function | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./AzureFunctions/km-charts-function | |
file: ./AzureFunctions/km-charts-function/Dockerfile | |
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' }} | |
tags: | | |
${{ secrets.ACR_LOGIN_SERVER }}/km-charts-function:${{ steps.determine_tag.outputs.tagname }} | |
${{ secrets.ACR_LOGIN_SERVER }}/km-charts-function:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }} |