From 29d398203dfa338bfe468258817082194cc48e86 Mon Sep 17 00:00:00 2001 From: Oleg Zhuk Date: Thu, 20 Jul 2023 09:51:33 +0200 Subject: [PATCH] Update workflow --- .github/workflows/module-ci.yml | 23 +- .github/workflows/module-release-hotfix.yml | 10 +- .github/workflows/module-sample-ci.yml | 266 ++++++++++++++++++++ .github/workflows/publish-nugets.yml | 8 +- .github/workflows/release.yml | 4 +- 5 files changed, 292 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/module-sample-ci.yml diff --git a/.github/workflows/module-ci.yml b/.github/workflows/module-ci.yml index 4b674e44..30a8a8ad 100644 --- a/.github/workflows/module-ci.yml +++ b/.github/workflows/module-ci.yml @@ -1,4 +1,4 @@ -# v3.200.20 +# v3.200.30 name: Module CI on: @@ -56,6 +56,11 @@ jobs: 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: | @@ -149,9 +154,9 @@ jobs: id: artifactUrl run: | if [ '${{ github.ref }}' = 'refs/heads/master' ]; then - echo ::set-output name=download_url::${{ steps.githubRelease.outputs.downloadUrl }} + echo "download_url=${{ steps.githubRelease.outputs.downloadUrl }}" >> $GITHUB_OUTPUT else - echo ::set-output name=download_url::${{ steps.blobRelease.outputs.packageUrl }} + echo "download_url=${{ steps.blobRelease.outputs.packageUrl }}" >> $GITHUB_OUTPUT fi; - name: Create deployment matrix @@ -167,9 +172,9 @@ jobs: run: | if [[ "${{ github.event.head_commit.message }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "::set-output name=result::false" + echo "result=false" >> $GITHUB_OUTPUT else - echo "::set-output name=result::true" + echo "result=true" >> $GITHUB_OUTPUT fi - name: Setup Git Credentials @@ -208,7 +213,7 @@ jobs: - 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 + uses: VirtoCommerce/jira-upload-build-info@master with: cloud-instance-base-url: '${{ secrets.CLOUD_INSTANCE_BASE_URL }}' client-id: '${{ secrets.CLIENT_ID }}' @@ -234,7 +239,7 @@ jobs: if: ${{ ((github.ref == 'refs/heads/dev') && (github.event_name == 'push') && (needs.ci.outputs.run-e2e == 'true')) || (github.event_name == 'workflow_dispatch')}} needs: 'ci' - uses: VirtoCommerce/.github/.github/workflows/e2e.yml@v3.200.20 + uses: VirtoCommerce/.github/.github/workflows/e2e.yml@v3.200.30 with: katalonRepo: 'VirtoCommerce/vc-quality-gate-katalon' katalonRepoBranch: 'dev' @@ -254,7 +259,7 @@ jobs: (github.ref == 'refs/heads/dev')) && github.event_name == 'push' }} needs: ci - uses: VirtoCommerce/.github/.github/workflows/deploy-cloud.yml@v3.200.20 + uses: VirtoCommerce/.github/.github/workflows/deploy-cloud.yml@v3.200.30 with: releaseSource: module moduleId: ${{ needs.ci.outputs.moduleId }} @@ -263,4 +268,4 @@ jobs: jiraKeys: ${{ needs.ci.outputs.jira-keys }} argoServer: 'argo.virtocommerce.cloud' matrix: '{"include":${{ needs.ci.outputs.matrix }}}' - secrets: inherit \ No newline at end of file + secrets: inherit diff --git a/.github/workflows/module-release-hotfix.yml b/.github/workflows/module-release-hotfix.yml index 21b8538d..7b95ce13 100644 --- a/.github/workflows/module-release-hotfix.yml +++ b/.github/workflows/module-release-hotfix.yml @@ -1,4 +1,4 @@ -# v3.200.20 +# v3.200.30 name: Release hotfix on: @@ -12,12 +12,12 @@ on: jobs: test: - uses: VirtoCommerce/.github/.github/workflows/test-and-sonar.yml@v3.200.20 + uses: VirtoCommerce/.github/.github/workflows/test-and-sonar.yml@v3.200.30 secrets: sonarToken: ${{ secrets.SONAR_TOKEN }} build: - uses: VirtoCommerce/.github/.github/workflows/build.yml@v3.200.20 + uses: VirtoCommerce/.github/.github/workflows/build.yml@v3.200.30 with: uploadPackage: 'true' uploadDocker: 'false' @@ -28,6 +28,8 @@ jobs: get-metadata: runs-on: ubuntu-20.04 + env: + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} outputs: changelog: ${{ steps.changelog.outputs.changelog }} steps: @@ -43,7 +45,7 @@ jobs: publish-github-release: needs: [build, test, get-metadata] - uses: VirtoCommerce/.github/.github/workflows/publish-github.yml@v3.200.20 + uses: VirtoCommerce/.github/.github/workflows/publish-github.yml@v3.200.30 with: fullKey: ${{ needs.build.outputs.packageFullKey }} changeLog: '${{ needs.get-metadata.outputs.changeLog }}' diff --git a/.github/workflows/module-sample-ci.yml b/.github/workflows/module-sample-ci.yml new file mode 100644 index 00000000..c7838fca --- /dev/null +++ b/.github/workflows/module-sample-ci.yml @@ -0,0 +1,266 @@ +# v1.0.1 +name: Module Sample CI + +on: + workflow_dispatch: + push: + branches: + [master, dev] + paths: + ['samples/**', '!**/argoDeploy.json'] + pull_request: + branches: + [master, dev] + paths: + ['samples/**', '!**/argoDeploy.json'] +jobs: + ci: + strategy: + matrix: + projectName: ['SampleModule.Web'] + + 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-latest + env: + CLOUD_INSTANCE_BASE_URL: ${{secrets.CLOUD_INSTANCE_BASE_URL}} + CLIENT_ID: ${{secrets.CLIENT_ID}} + CLIENT_SECRET: ${{secrets.CLIENT_SECRET}} + SONAR_TOKEN: ${{secrets.SONAR_TOKEN}} + 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.blobRelease.outputs.packageUrl }} + jira-keys: ${{ steps.jira_keys.outputs.jira-keys }} + + steps: + + - name: Set RELEASE_STATUS + if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }} + run: | + echo "RELEASE_STATUS=true" >> $GITHUB_ENV + + - name: Set up JDK 11 for dotnet-sonarscanner #Sonar stop accepting Java versions less than 11 + uses: actions/setup-java@v1 + with: + java-version: 1.11 + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install VirtoCommerce.GlobalTool + uses: VirtoCommerce/vc-github-actions/setup-vcbuild@master + + - name: Install dotnet-sonarscanner + run: dotnet tool install --global dotnet-sonarscanner + + - name: Get changelog + id: changelog + uses: VirtoCommerce/vc-github-actions/changelog-generator@master + + - name: Get Image Version + uses: VirtoCommerce/vc-github-actions/get-image-version@master + id: image + + - name: Set VERSION_SUFFIX variable + run: | + if [ '${{ github.event_name }}' = 'workflow_dispatch' ]; then + echo "VERSION_SUFFIX=${{ steps.image.outputs.fullSuffix }}" >> $GITHUB_ENV + else + echo "VERSION_SUFFIX=${{ steps.image.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: SonarCloud Begin + uses: VirtoCommerce/vc-github-actions/sonar-scanner-begin@master + + - name: Build + run: vc-build Compile -DefaultProject "${{ matrix.projectName }}" + + - name: Unit Tests + run: vc-build Test -skip -DefaultProject "${{ matrix.projectName }}" + + - name: SonarCloud End + uses: VirtoCommerce/vc-github-actions/sonar-scanner-end@master + + - name: Quality Gate + uses: VirtoCommerce/vc-github-actions/sonar-quality-gate@master + with: + login: ${{secrets.SONAR_TOKEN}} + + - name: Packaging + run: vc-build Compress -skip Clean+Restore+Compile+Test -DefaultProject "${{ matrix.projectName }}" + + - name: Rename artifact + run: | + cd artifacts + for zip in *.zip + do + newzip="${{ matrix.projectName }}-sample-${zip}" + mv "${zip}" "${newzip}" + echo "${zip} renamed to ${newzip}" + done + + - name: Publish to Blob + if: ${{ 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 link to PR + if: ${{ github.event_name == 'pull_request' }} + uses: VirtoCommerce/vc-github-actions/publish-artifact-link@master + with: + artifactUrl: ${{ steps.blobRelease.outputs.packageUrl }} + downloadComment: 'Artifact URL:' + + - name: Publish Github Release + if: ${{ github.ref == 'refs/heads/master' }} + with: + changelog: ${{ steps.changelog.outputs.changelog }} + uses: VirtoCommerce/vc-github-actions/publish-github-release@master + + - 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: + if: ${{ github.ref == 'refs/heads/dev' && github.event_name != 'workflow_dispatch' }} + needs: ci + runs-on: ubuntu-latest + strategy: + matrix: + environment: [dev, qa] + + env: + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} + CLOUD_INSTANCE_BASE_URL: ${{secrets.CLOUD_INSTANCE_BASE_URL}} + CLIENT_ID: ${{secrets.CLIENT_ID}} + CLIENT_SECRET: ${{secrets.CLIENT_SECRET}} + + steps: + - name: Read deployment config + uses: VirtoCommerce/vc-github-actions/get-deploy-param@master + id: deployConfig + with: + envName: ${{ matrix.environment }} + deployConfigPath: '.deployment/samples/argoDeploy.json' + + - name: Start deployment + uses: bobheadxi/deployments@master + id: deployment + with: + step: start + token: ${{ secrets.GITHUB_TOKEN }} + env: ${{ steps.deployConfig.outputs.environmentName }} + no_override: false + + - name: Update deployment-cm + uses: VirtoCommerce/vc-github-actions/create-deploy-pr@master + with: + deployRepo: ${{ steps.deployConfig.outputs.deployRepo }} + deployBranch: ${{ steps.deployConfig.outputs.deployBranch }} + artifactKey: ${{ steps.deployConfig.outputs.artifactKey }} + artifactUrl: ${{ needs.ci.outputs.artifactUrl }} + taskNumber: 'undefined' + forceCommit: 'true' + cmPath: ${{ steps.deployConfig.outputs.cmPath }} + + - name: Wait for environment is up + shell: pwsh + timeout-minutes: 15 + run: | + do { + Start-Sleep -s 15 + $statusBage = (Invoke-WebRequest -Uri "https://argo.govirto.com/api/badge?name=${{ steps.deployConfig.outputs.deployAppName }}").Content + + $syncedAndHealthy = $statusBage.Contains('>Healthy<') -and $statusBage.Contains('>Synced<') + if (-not $syncedAndHealthy) { + Write-Host "Sync pending..." + } + } + while (-not $syncedAndHealthy) + + - name: DEPLOY_STATE::successful + if: success() + run: echo "DEPLOY_STATE=successful" >> $GITHUB_ENV + + - name: DEPLOY_STATE::failed + if: failure() + run: echo "DEPLOY_STATE=failed" >> $GITHUB_ENV + + - name: Update GitHub deployment status + uses: bobheadxi/deployments@master + if: always() + with: + step: finish + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + + - name: Push Deployment Info to Jira + if: ${{ env.CLOUD_INSTANCE_BASE_URL != 0 && env.CLIENT_ID != 0 && env.CLIENT_SECRET != 0 && needs.ci.outputs.jira-keys != '' && always() }} + id: push_deployment_info_to_jira + uses: HighwayThree/jira-upload-deployment-info@master + env: + CLOUD_INSTANCE_BASE_URL: ${{secrets.CLOUD_INSTANCE_BASE_URL}} + CLIENT_ID: ${{secrets.CLIENT_ID}} + CLIENT_SECRET: ${{secrets.CLIENT_SECRET}} + with: + cloud-instance-base-url: ${{ secrets.CLOUD_INSTANCE_BASE_URL }} + client-id: ${{ secrets.CLIENT_ID }} + client-secret: ${{ secrets.CLIENT_SECRET }} + deployment-sequence-number: ${{ github.run_id }} + update-sequence-number: ${{ github.run_id }} + issue-keys: ${{ needs.ci.outputs.jira-keys }} + display-name: ${{ steps.deployConfig.outputs.deployAppName }} + url: ${{ steps.deployConfig.outputs.environmentUrl }} + description: 'Deployment to the ${{ steps.deployConfig.outputs.environmentName }} environment' + last-updated: '${{github.event.head_commit.timestamp}}' + state: '${{ env.DEPLOY_STATE }}' + pipeline-id: '${{ github.repository }} ${{ github.workflow }}' + pipeline-display-name: 'Workflow: ${{ github.workflow }} (#${{ github.run_number }})' + pipeline-url: '${{github.event.repository.html_url}}/actions/runs/${{github.run_id}}' + environment-id: ${{ steps.deployConfig.outputs.environmentId }} + environment-display-name: ${{ steps.deployConfig.outputs.environmentName }} + environment-type: ${{ steps.deployConfig.outputs.environmentType }} diff --git a/.github/workflows/publish-nugets.yml b/.github/workflows/publish-nugets.yml index f9800781..fe559383 100644 --- a/.github/workflows/publish-nugets.yml +++ b/.github/workflows/publish-nugets.yml @@ -1,4 +1,4 @@ -# v3.200.20 +# v3.200.30 name: Publish nuget on: @@ -12,12 +12,12 @@ on: jobs: test: - uses: VirtoCommerce/.github/.github/workflows/test-and-sonar.yml@v3.200.20 + uses: VirtoCommerce/.github/.github/workflows/test-and-sonar.yml@v3.200.30 secrets: sonarToken: ${{ secrets.SONAR_TOKEN }} build: - uses: VirtoCommerce/.github/.github/workflows/build.yml@v3.200.20 + uses: VirtoCommerce/.github/.github/workflows/build.yml@v3.200.30 with: uploadPackage: 'true' uploadDocker: 'false' @@ -28,7 +28,7 @@ jobs: publish-nuget: needs: [build, test] - uses: VirtoCommerce/.github/.github/workflows/publish-github.yml@v3.200.20 + uses: VirtoCommerce/.github/.github/workflows/publish-github.yml@v3.200.30 with: fullKey: ${{ needs.build.outputs.packageFullKey }} forceGithub: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aea2498e..1d96b557 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -# v3.200.20 +# v3.200.30 name: Release on: @@ -6,6 +6,6 @@ on: jobs: release: - uses: VirtoCommerce/.github/.github/workflows/release.yml@v3.200.20 + uses: VirtoCommerce/.github/.github/workflows/release.yml@v3.200.30 secrets: envPAT: ${{ secrets.REPO_TOKEN }} \ No newline at end of file