create a sample agent #5
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 | |
- hotfix | |
pull_request: | |
types: | |
- opened | |
- ready_for_review | |
- reopened | |
- synchronize | |
branches: | |
- main | |
- dev | |
- demo | |
- hotfix | |
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.ref_name == 'main' }} | |
uses: azure/docker-login@v2 | |
with: | |
login-server: ${{ secrets.ACR_LOGIN_SERVER }} | |
username: ${{ secrets.ACR_USERNAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
- name: Log in to Azure Container Registry (Dev/Demo) | |
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }} | |
uses: azure/docker-login@v2 | |
with: | |
login-server: ${{ secrets.ACR_DEV_LOGIN_SERVER }} | |
username: ${{ secrets.ACR_DEV_USERNAME }} | |
password: ${{ secrets.ACR_DEV_PASSWORD }} | |
- name: Set Docker image tag | |
run: | | |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
echo "TAG=latest" >> $GITHUB_ENV | |
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then | |
echo "TAG=dev" >> $GITHUB_ENV | |
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then | |
echo "TAG=demo" >> $GITHUB_ENV | |
elif [[ "${{ github.ref }}" == "refs/heads/hotfix" ]]; then | |
echo "TAG=hotfix" >> $GITHUB_ENV | |
fi | |
- name: Build and push Docker images | |
if: ${{ github.ref_name == 'main' }} | |
run: | | |
cd src/backend | |
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} -f Dockerfile . && \ | |
docker push ${{ secrets.ACR_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} && \ | |
echo "Backend image built and pushed successfully." | |
cd ../frontend | |
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} -f Dockerfile . && \ | |
docker push ${{ secrets.ACR_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} && \ | |
echo "Frontend image built and pushed successfully." | |
- name: Build and push Docker images (Dev/Demo/hotfix) | |
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' || github.ref_name == 'hotfix' }} | |
run: | | |
cd src/backend | |
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} -f Dockerfile . && \ | |
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/macae-backend:${{ env.TAG }} && \ | |
echo "Dev/Demo/Hotfix Backend image built and pushed successfully." | |
cd ../frontend | |
docker build -t ${{ secrets.ACR_DEV_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} -f Dockerfile . && \ | |
docker push ${{ secrets.ACR_DEV_LOGIN_SERVER }}/mac-webapp:${{ env.TAG }} && \ | |
echo "Dev/Demo/Hotfix Frontend image built and pushed successfully." | |