Skip to content

Commit

Permalink
VM-1483: ci cd for communication module
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-buravlev committed Oct 23, 2024
1 parent 7715003 commit c3c69fc
Show file tree
Hide file tree
Showing 4 changed files with 230 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .deployment/module/argoDeploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"artifactKey": "VirtoCommerce.Communication",
"deployRepo": "vc-deploy-marketplace",
"cmPath": "marketplace-app/resources/deployment-cm.yaml",
"dev": {
"deployAppName": "marketplace-app-dev",
"deployBranch": "dev",
"environmentId" : "dev",
"environmentName" : "Development",
"environmentType" : "staging",
"environmentUrl" : "https://vendor-portal.dev.govirto.com/"
}
}
13 changes: 13 additions & 0 deletions .deployment/module/cloudDeploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"artifactKey": "VirtoCommerce.Communication",
"deployRepo": "vc-deploy-marketplace",
"cmPath": "backend/packages.json",
"dev": {
"deployAppName": "vcmp-dev",
"deployBranch": "vcmp-dev",
"environmentId" : "dev",
"environmentName" : "Development",
"environmentType" : "staging",
"environmentUrl" : "https://vcmp-dev.govirto.com/"
}
}
193 changes: 193 additions & 0 deletions .github/workflows/module-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# v3.200.30
name: Module CI

on:
workflow_dispatch:
push:
paths-ignore:
- '.github/**'
- 'docs/**'
- 'build/**'
- 'README.md'
- 'LICENSE'
- '**/argoDeploy.json'
- '**/cloudDeploy.json'
- samples/**
branches:
[master, dev]
pull_request:
branches:
[master, dev]
paths-ignore:
- 'docs/**'
- 'build/**'
- 'README.md'
- 'LICENSE'
- '**/argoDeploy.json'
- '**/cloudDeploy.json'
- samples/**

jobs:
ci:
if: ${{ github.actor != 'dependabot[bot]' &&
(github.event.pull_request.head.repo.full_name == github.repository ||
github.event.pull_request.head.repo.full_name == '') }} # Check that PR not from forked repo and not from Dependabot
runs-on: ubuntu-20.04
env:
CLOUD_INSTANCE_BASE_URL: ${{secrets.CLOUD_INSTANCE_BASE_URL}}
CLIENT_ID: ${{secrets.CLIENT_ID}}
CLIENT_SECRET: ${{secrets.CLIENT_SECRET}}
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
NUGET_KEY: ${{ secrets.NUGET_KEY }}
BLOB_SAS: ${{ secrets.BLOB_TOKEN }}
VERSION_SUFFIX: ''
BUILD_STATE: 'failed'
RELEASE_STATUS: 'false'

outputs:
artifactUrl: ${{ steps.artifactUrl.outputs.download_url }}
blobId: ${{ steps.blobRelease.outputs.blobId }}
jira-keys: ${{ steps.jira_keys.outputs.jira-keys }}
version: ${{ steps.artifact_ver.outputs.shortVersion }}
moduleId: ${{ steps.artifact_ver.outputs.moduleId }}
matrix: ${{ steps.deployment-matrix.outputs.matrix }}

steps:

- name: Set up Node 18
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Set RELEASE_STATUS
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
run: |
echo "RELEASE_STATUS=true" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install VirtoCommerce.GlobalTool
uses: VirtoCommerce/vc-github-actions/setup-vcbuild@master

- name: Get Changelog
id: changelog
uses: VirtoCommerce/vc-github-actions/changelog-generator@master

- name: Get Artifact Version
uses: VirtoCommerce/vc-github-actions/get-image-version@master
id: artifact_ver

- name: Set VERSION_SUFFIX variable
run: |
if [ '${{ github.event_name }}' = 'workflow_dispatch' ]; then
echo "VERSION_SUFFIX=${{ steps.artifact_ver.outputs.fullSuffix }}-${{ github.run_id }}-${{ github.run_attempt }}" >> $GITHUB_ENV
else
echo "VERSION_SUFFIX=${{ steps.artifact_ver.outputs.suffix }}" >> $GITHUB_ENV
fi;
- name: Add version suffix
if: ${{ github.ref != 'refs/heads/master' }}
uses: VirtoCommerce/vc-github-actions/add-version-suffix@master
with:
versionSuffix: ${{ env.VERSION_SUFFIX }}

- name: Build
run: vc-build Compile

- name: Unit Tests
run: vc-build Test -skip

- name: Packaging
run: vc-build Compress -skip Clean+Restore+Compile+Test

- name: Publish Nuget
if: ${{ (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master') && github.event_name != 'workflow_dispatch' }}
uses: VirtoCommerce/vc-github-actions/publish-nuget@master

- name: Publish to Blob
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/master') }}
id: blobRelease
uses: VirtoCommerce/vc-github-actions/publish-blob-release@master
with:
blobSAS: ${{ secrets.BLOB_TOKEN }}

- name: Add Jira link
if: ${{ github.event_name == 'pull_request' }}
uses: VirtoCommerce/vc-github-actions/publish-jira-link@master
with:
branchName: ${{ github.head_ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Github Release
if: ${{ github.ref == 'refs/heads/master' }}
id: githubRelease
with:
changelog: ${{ steps.changelog.outputs.changelog }}
uses: VirtoCommerce/vc-github-actions/publish-github-release@master

- name: Set artifactUrl value
id: artifactUrl
run: |
if [ '${{ github.ref }}' = 'refs/heads/master' ]; then
echo "download_url=${{ steps.githubRelease.outputs.downloadUrl }}" >> $GITHUB_OUTPUT
else
echo "download_url=${{ steps.blobRelease.outputs.packageUrl }}" >> $GITHUB_OUTPUT
fi;
- name: Create deployment matrix
if: ${{ github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master'}}
uses: VirtoCommerce/vc-github-actions/cloud-create-deploy-matrix@master
id: deployment-matrix
with:
deployConfigPath: '.deployment/module/cloudDeploy.json'
releaseBranch: 'non-existent'

- name: Parse Jira Keys from All Commits
uses: VirtoCommerce/vc-github-actions/get-jira-keys@master
if: always()
id: jira_keys
with:
release: ${{ env.RELEASE_STATUS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Push Build Info to Jira
if: ${{ env.CLOUD_INSTANCE_BASE_URL != 0 && env.CLIENT_ID != 0 && env.CLIENT_SECRET != 0 && steps.jira_keys.outputs.jira-keys != '' && always() }}
id: push_build_info_to_jira
uses: HighwayThree/jira-upload-build-info@master
with:
cloud-instance-base-url: '${{ secrets.CLOUD_INSTANCE_BASE_URL }}'
client-id: '${{ secrets.CLIENT_ID }}'
client-secret: '${{ secrets.CLIENT_SECRET }}'
pipeline-id: '${{ github.repository }} ${{ github.workflow }}'
build-number: ${{ github.run_number }}
build-display-name: 'Workflow: ${{ github.workflow }} (#${{ github.run_number }})'
build-state: '${{ env.BUILD_STATE }}'
build-url: '${{github.event.repository.url}}/actions/runs/${{github.run_id}}'
update-sequence-number: '${{ github.run_id }}'
last-updated: '${{github.event.head_commit.timestamp}}'
issue-keys: '${{ steps.jira_keys.outputs.jira-keys }}'
commit-id: '${{ github.sha }}'
repo-url: '${{ github.event.repository.url }}'
build-ref-url: '${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}'

- name: Confirm Jira Build Output
if: success()
run: |
echo "Jira Upload Build Info response: ${{ steps.push_build_info_to_jira.outputs.response }}"
deploy-cloud:
if: ${{ (github.ref == 'refs/heads/master') || (github.ref == 'refs/heads/dev') }}
needs: ci
uses: VirtoCommerce/.github/.github/workflows/deploy-cloud.yml@v3.200.35
with:
releaseSource: module
moduleId: ${{ needs.ci.outputs.moduleId }}
moduleVer: ${{ needs.ci.outputs.version }}
moduleBlob: ${{ needs.ci.outputs.blobId }}
jiraKeys: ${{ needs.ci.outputs.jira-keys }}
argoServer: 'argo.virtocommerce.cloud'
matrix: '{"include":${{ needs.ci.outputs.matrix }}}'
secrets: inherit
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# v3.200.30
name: Release

on:
workflow_dispatch:

jobs:
release:
uses: VirtoCommerce/.github/.github/workflows/release.yml@v3.200.30
secrets:
envPAT: ${{ secrets.REPO_TOKEN }}

0 comments on commit c3c69fc

Please sign in to comment.