Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.0.0 GitHub action #9312

Merged
4 changes: 2 additions & 2 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Build-Test
on:
push:
branches:
- "*" # Trigger on push to any branch
- "test" # Trigger on push to any branch
pull_request:
branches:
- "*" # Trigger on pull request to any branch
- "test" # Trigger on pull request to any branch

jobs:
ci-cd-TestCases:
Expand Down
47 changes: 17 additions & 30 deletions .github/workflows/build-upload-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Build and Upload Artifact
on:
push:
branches:
- "deploy" # Trigger on push to the "deploy" branch
- "*" # Trigger on push to the "deploy" branch
pull_request:
branches:
- "deploy" # Trigger on pull request to the "deploy" branch
- "*" # Trigger on pull request to the "deploy" branch

jobs:
build_and_deploy:
Expand Down Expand Up @@ -37,40 +37,27 @@ jobs:
commit_hash=$(git rev-parse --short HEAD) # Get commit hash
build_tag=$(echo "${{ github.ref }}" | rev | cut -d/ -f1 | rev)_${commit_hash}_${GITHUB_RUN_NUMBER} # Generate build tag
echo "build_tag=$build_tag" >> $GITHUB_ENV # Save build tag to environment variable
bash ./build.sh "${build_tag}" "${{ env.NODE_NAME }}" "test" true false "" # Run build script with parameters
docker build -t myapp:${build_tag} . # Build Docker image
env:
NODE_NAME: "18.20.2" # Set environment variable NODE_NAME

# - name: Log in to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Push Docker Image
# run: |
# docker tag my-app:${{ env.build_tag }} ${{ secrets.DOCKER_USERNAME }}/my-app:${{ env.build_tag }}
# docker push ${{ secrets.DOCKER_USERNAME }}/my-app:${{ env.build_tag }}
- name: Docker Login
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.AZURE_URL }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}

# - name: Push Docker Image
# uses: docker/build-push-action@v4
# with:
# context: .
# # file: ./Dockerfile # Path to your Dockerfile
# push: true
# tags: ${{ secrets.DOCKER_USERNAME }}/my-app:${{ env.build_tag }}
- name: Build and Push to ACR
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.AZURE_URL }}/myapp:${{ env.build_tag }}
file: Dockerfile

- name: Archive Artifacts
uses: actions/upload-artifact@v2
with:
name: metadata
path: metadata.json

- name: Archive CDN assets if required
if: ${{ github.event.inputs.buildCdnAssests == 'true' }} # Conditional step execution
run: |
rm -rf cdn_assets # Remove existing CDN assets directory
mkdir cdn_assets # Create CDN assets directory
cp -r src/app/dist-cdn/* cdn_assets/ # Copy CDN assets
zip -Jr cdn_assets.zip cdn_assets # Create zip file of CDN assets
echo "##vso[task.uploadfile]cdn_assets.zip" # Upload CDN assets zip file
path: myapp_${{ env.build_tag }}.tar
Loading