From b101789fc7d9b316f16f8548dca0bc39dac7eb83 Mon Sep 17 00:00:00 2001 From: Prashant-Microsoft Date: Thu, 31 Oct 2024 13:27:45 +0530 Subject: [PATCH 1/2] testing docker file --- .github/workflows/build-docker-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 48f29b13..d3d454b3 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -22,7 +22,7 @@ jobs: # registry: bycwacontainerreg.azurecr.io # username: bycwacontainerreg - - app_name: byoaia-app + - app_name: byoaires-app dockerfile: ResearchAssistant/App/WebApp.Dockerfile registry: resasscontainerreg.azurecr.io username: resasscontainerreg From d79d786e6e7b0a73bc031c861f6e141fcfec6496 Mon Sep 17 00:00:00 2001 From: Prashant-Microsoft Date: Thu, 31 Oct 2024 13:30:00 +0530 Subject: [PATCH 2/2] modify code --- .github/workflows/build-docker-images.yml | 2 +- test/ci.yml | 93 +++++++++++++++++++++++ test/create-release.yml | 67 ++++++++++++++++ 3 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 test/ci.yml create mode 100644 test/create-release.yml diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index d3d454b3..08e82af1 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -33,5 +33,5 @@ jobs: username: ${{ matrix.username }} app_name: ${{ matrix.app_name }} dockerfile: ${{ matrix.dockerfile }} - push: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' }} + push: ${{ github.event.workflow_run.head_branch == 'main' }} secrets: inherit diff --git a/test/ci.yml b/test/ci.yml new file mode 100644 index 00000000..8edfe895 --- /dev/null +++ b/test/ci.yml @@ -0,0 +1,93 @@ +name: CI + +on: + push: + branches: + - main + schedule: + - cron: '0 6,18 * * *' # Runs at 6:00 AM and 6:00 PM GMT + +permissions: + contents: read + packages: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + ci: + runs-on: ubuntu-latest + env: + AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} + AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pre-build image and run make in dev container + uses: devcontainers/ci@v0.3 + env: + AZURE_ENV_NAME: ${{ github.run_id }} + AZURE_LOCATION: ${{ vars.AZURE_LOCATION }} + AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }} + with: + imageName: ghcr.io/roopan-microsoft/psl-cwyd-main + cacheFrom: ghcr.io/roopan-microsoft/psl-cwyd-main + runCmd: make ci && make deploy + refFilterForPush: refs/heads/main + env: | + AZURE_CLIENT_ID + AZURE_CLIENT_SECRET + AZURE_TENANT_ID + AZURE_SUBSCRIPTION_ID + AZURE_ENV_NAME + AZURE_LOCATION + AZURE_RESOURCE_GROUP + + - name: Tidy up + uses: devcontainers/ci@v0.3 + if: always() + env: + AZURE_ENV_NAME: ${{ github.run_id }} + AZURE_LOCATION: ${{ vars.AZURE_LOCATION }} + AZURE_RESOURCE_GROUP: ${{ vars.AZURE_RESOURCE_GROUP }} + with: + push: never + imageName: ghcr.io/roopan-microsoft/psl-cwyd-main + runCmd: make destroy + env: | + AZURE_CLIENT_ID + AZURE_CLIENT_SECRET + AZURE_TENANT_ID + AZURE_SUBSCRIPTION_ID + AZURE_ENV_NAME + AZURE_LOCATION + AZURE_RESOURCE_GROUP + + - name: Send Notification on Failure + if: failure() + run: | + RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + + # Construct the email body + EMAIL_BODY=$(cat <Dear Team,

We would like to inform you that the CWYD Automation process has encountered an issue and has failed to complete successfully.

Build URL: ${RUN_URL}
${OUTPUT}

Please investigate the matter at your earliest convenience.

Best regards,
Your Automation Team

" + } + EOF + ) + + # Send the notification + curl -X POST "${{ secrets.LOGIC_APP_URL }}" \ + -H "Content-Type: application/json" \ + -d "$EMAIL_BODY" || echo "Failed to send notification" diff --git a/test/create-release.yml b/test/create-release.yml new file mode 100644 index 00000000..1e3776bd --- /dev/null +++ b/test/create-release.yml @@ -0,0 +1,67 @@ +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +permissions: + contents: write + pull-requests: write + +name: create-release + +jobs: + create-release: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} + + - uses: codfish/semantic-release-action@v3 + id: semantic + with: + tag-format: 'v${version}' + additional-packages: | + ['conventional-changelog-conventionalcommits@7'] + plugins: | + [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits" + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { type: 'feat', section: 'Features', hidden: false }, + { type: 'fix', section: 'Bug Fixes', hidden: false }, + { type: 'perf', section: 'Performance Improvements', hidden: false }, + { type: 'revert', section: 'Reverts', hidden: false }, + { type: 'docs', section: 'Other Updates', hidden: false }, + { type: 'style', section: 'Other Updates', hidden: false }, + { type: 'chore', section: 'Other Updates', hidden: false }, + { type: 'refactor', section: 'Other Updates', hidden: false }, + { type: 'test', section: 'Other Updates', hidden: false }, + { type: 'build', section: 'Other Updates', hidden: false }, + { type: 'ci', section: 'Other Updates', hidden: false } + ] + } + } + ], + '@semantic-release/github' + ] + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - run: echo ${{ steps.semantic.outputs.release-version }} + + - run: echo "$OUTPUTS" + env: + OUTPUTS: ${{ toJson(steps.semantic.outputs) }}