Merge pull request #24 from pmalarme/patch-1 #23
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: CI_CD_Dev | |
on: | |
push: | |
branches: | |
- master | |
- FluxV2 | |
- release/* | |
jobs: | |
Build_Push_Azure_Vote_App_Image: | |
runs-on: ubuntu-latest | |
env: | |
SRC_FOLDER: azure-vote | |
IMAGE_REPO_NAME: azvote | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Azure Login | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Create Frontend Image Tags | |
env: | |
SOURCE_LOCATION: src/azure-vote-front | |
DOCKER_FILE: Dockerfile | |
IMAGE_NAME: azure-vote-front | |
TASKNAME: FRONTEND_IMAGE | |
AZ_ACR_NAME: ${{ secrets.AZ_ACR_NAME }} | |
uses: Azure/[email protected] | |
with: | |
inlineScript: | | |
chmod +x $GITHUB_WORKSPACE/utils/buildContainerTemplate.sh | |
$GITHUB_WORKSPACE/utils/buildContainerTemplate.sh -f $SRC_FOLDER \ | |
-g $GITHUB_WORKSPACE \ | |
-s $SOURCE_LOCATION \ | |
-u $AZ_ACR_NAME \ | |
-r $IMAGE_REPO_NAME/$IMAGE_NAME \ | |
-t $TASKNAME \ | |
-d $DOCKER_FILE | |
- name: Create Backend Image Tags | |
env: | |
SOURCE_LOCATION: src/azure-vote-back | |
DOCKER_FILE: Dockerfile | |
IMAGE_NAME: azure-vote-back | |
TASKNAME: BACKEND_IMAGE | |
AZ_ACR_NAME: ${{ secrets.AZ_ACR_NAME }} | |
uses: Azure/[email protected] | |
with: | |
inlineScript: | | |
chmod +x $GITHUB_WORKSPACE/utils/buildContainerTemplate.sh | |
$GITHUB_WORKSPACE/utils/buildContainerTemplate.sh -f $SRC_FOLDER \ | |
-g $GITHUB_WORKSPACE \ | |
-s $SOURCE_LOCATION \ | |
-u $AZ_ACR_NAME \ | |
-r $IMAGE_REPO_NAME/$IMAGE_NAME \ | |
-t $TASKNAME \ | |
-d $DOCKER_FILE | |
- name: Upload Image Tags | |
uses: actions/[email protected] | |
with: | |
name: image_tags | |
path: ${{ github.workspace }}/image_tags | |
- name: Upload Manifests Templates | |
uses: actions/[email protected] | |
with: | |
name: manifests | |
path: ${{ github.workspace }}/azure-vote/manifests | |
- name: Upload Utils | |
uses: actions/[email protected] | |
with: | |
name: utils | |
path: ${{ github.workspace }}/utils | |
Deploy_to_Dev: | |
name: "Deploy to Dev" | |
runs-on: ubuntu-latest | |
needs: Build_Push_Azure_Vote_App_Image | |
environment: az-vote-app-dev | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Download Image Tags | |
uses: actions/[email protected] | |
with: | |
name: image_tags | |
path: ${{ github.workspace }}/image_tags | |
- name: Download Manifests Templates | |
uses: actions/[email protected] | |
with: | |
name: manifests | |
path: ${{ github.workspace }}/manifests | |
- name: Download Utils | |
uses: actions/[email protected] | |
with: | |
name: utils | |
path: ${{ github.workspace }}/utils | |
- name: Read Image Tags | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' | |
run: | | |
for file in ${{ github.workspace }}/image_tags/*; do echo "::set-env name=${file##*/}::$(cat $file)"; done | |
- name: Generate Manifests | |
run: | | |
${{ github.workspace }}/utils/generate-manifests.sh manifests gen_manifests | |
env: | |
TARGET_NAMESPACE: ${{ secrets.TARGET_NAMESPACE }} | |
VOTE_APP_TITLE: ${{ secrets.VOTE_APP_TITLE }} | |
DEMO_APP_URL: ${{ secrets.DEMO_APP_URL }} | |
AZURE_VOTE_IMAGE_REPO: ${{ secrets.AZ_ACR_NAME }}/.azurecr.io/${{ env.IMAGE_REPO_NAME }} | |
SYSTEM_LABEL: ${{ secrets.SYSTEM_LABEL }} | |
- name: Create PR | |
run: | | |
# Extract release number from the branch name | |
# If it is a release branch, add a prefix to the manifests branch | |
echo $GITHUB_REF | awk -F"release/" '{print $2}' | |
release_number=$(echo $GITHUB_REF | awk -F"release/" '{print $2}') | |
[[ -z "$release_number" ]] || release_prefix=release/$release_number/ | |
${{ github.workspace }}/utils/create-pr.sh -s ${{ github.workspace }}/gen_manifests -d ${{ secrets.MANIFESTS_FOLDER }} -r ${{ secrets.MANIFESTS_REPO }} -b $(echo $release_prefix)${{ secrets.MANIFESTS_BRANCH }} -i $GITHUB_RUN_ID -t ${{ secrets.PAT }} -e ${{ secrets.ENVIRONMENT_NAME }} | |