Skip to content

Merge pull request #27 from thattonBL/development #106

Merge pull request #27 from thattonBL/development

Merge pull request #27 from thattonBL/development #106

Workflow file for this run

name: Build and Publish Docker Image to Docker Hub and Trigger Azure Release
on:
push:
branches:
- main
- development
pull_request:
branches:
- main
- development
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v2
# Step 2: Extract the Version tag from the Docker File
- name: Extract Version Tag
id: extract_version
run: |
VERSION=$(grep 'LABEL version=' Building33MockApi/Dockerfile | sed 's/.*"\(.*\)"/\1/')
echo "VERSION=$VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Step 2: Login to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
# Step 3: Build the Docker image
- name: Build Docker image
run: |
echo "VERSION=$VERSION"
echo "VERSION from GITHUB_ENV is: ${{ env.VERSION }}"
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/building33mockapi:latest -t ${{ secrets.DOCKER_HUB_USERNAME }}/building33mockapi:${{ env.VERSION }} -f Building33MockApi/Dockerfile .
# Step 4: Push Docker image to Docker Hub
- name: Push Docker image to Docker Hub
run: |
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/building33mockapi:latest
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/building33mockapi:${{ env.VERSION }}
# Step 5: Trigger Azure Release Pipeline
- name: Trigger Azure DevOps Pipeline
uses: Azure/[email protected]
with:
azure-devops-project-url: ${{ secrets.AZURE_DEVOPS_PROJECT_URL }}
azure-pipeline-name: 'thattonBL.Building33MockApi'
azure-devops-token: ${{ secrets.AZURE_DEVOPS_PAT }}
azure-pipeline-variables: '{"DOCKER_IMAGE_VERSION": "${{ env.VERSION }}"}'
- uses: actions/checkout@v2