Skip to content

PT-14740: .net 8

PT-14740: .net 8 #48

# 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 }}