Skip to content

Commit

Permalink
🚧Update workflows (#645)
Browse files Browse the repository at this point in the history
* Start work for issue #642

* ci: update reusable workflow refs from v6.2.1 to version v9.0.0

* ci: update reusable workflow refs from v7.2.1 to version v9.0.0

* ci: update status checks

* ci: update release workflow

* ci: create prepare release workflow

* ci: improve workflows

* ide: improve settings and setup for ide tools

* docs: fix badges

* ci: change renovate to run off of the preview branch

* config: simple editor config update

* ide: update snippets

* docs: move location of release notes

* chore: move location of images

* ide: update tab settings

* docs: update readme logo

* ci: update release workflow input

* ci: update status check run names

* ci: improve prepare release workflow

* ide: update tab settings

* ci: fix workflow command syntax

* ci: update reusable workflow ref versions

* ide: update settings

* ci: rename sonar workflow job

* force status checks
  • Loading branch information
CalvinWilkinson authored Jul 21, 2023
1 parent 921ad54 commit 4ecec74
Show file tree
Hide file tree
Showing 74 changed files with 256 additions and 279 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,5 @@ dotnet_diagnostic.CA1853.severity = warning
csharp_prefer_simple_using_statement = true:suggestion

# Using directives must be placed inside of a namespace declaration
# IDE0065: Misplaced using directive
csharp_using_directive_placement = inside_namespace
6 changes: 0 additions & 6 deletions .github/.vscode/settings.json

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/add-new-issue-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:
jobs:
add_new_issue_to_project:
name: Add New Issue
uses: KinsonDigital/Infrastructure/.github/workflows/reusable/add-issue-to-project.yml@v9.0.0
uses: KinsonDigital/Infrastructure/.github/workflows/add-issue-to-project.yml@v10.0.1
with:
org-name: "${{ vars.ORGANIZATION_NAME }}"
org-project-name: "${{ vars.ORG_PROJECT_NAME }}"
project-name: "${{ vars.PROJECT_NAME }}"
secrets:
cicd-pat: ${{ secrets.CICD_REST_API }}
cicd-pat: ${{ secrets.CICD_TOKEN }}
41 changes: 0 additions & 41 deletions .github/workflows/build-pr-status-check.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/build-status-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: ✅Build Status Check
run-name: ✅Build Status Check (${{ github.base_ref }} branch)


defaults:
run:
shell: pwsh


on:
pull_request:
branches: [main, preview]


jobs:
build_status_check:
name: ${{ vars.PROJECT_NAME }} Build Status Check
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v10.0.1
with:
project-name: "${{ vars.PROJECT_NAME }}"
build-config: Debug
net-sdk-version: "${{ vars.NET_SDK_VERSION }}"
83 changes: 83 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: 🚁Prepare Release
run-name: 🚁Prepare ${{ inputs.release-type }} Release (${{ inputs.release-version }})


defaults:
run:
shell: pwsh


on:
workflow_dispatch:
inputs:
release-type:
description: The type of release. Choose 'Preview' or 'Production'.
required: true
type: choice
options: [Preview, Production]
release-version:
required: true
description: The version of the release to prepare.
type: string


jobs:
print_validate_workflow:
name: Print & Validate Prepare Release Workflow
runs-on: ubuntu-latest
steps:
- name: Print Environment Variables
run: Get-ChildItem -Path Env:* | Sort-Object Name

- name: Validate Workflow Inputs
run: |
$releaseType = "${{ inputs.release-type }}".ToLower();
if ("${{ vars.PROJECT_NAME }}".Trim() -eq "") {
Write-Host "::error::The project name input cannot be empty.";
exit 1;
}
if ($releaseType -eq "") {
Write-Host "::error::The release type input cannot be empty.";
exit 1;
}
if ($releaseType -ne 'preview' -and $releaseType -ne 'roduction') {
Write-Host "::error::The release type input must be either 'Preview' or 'Production'.";
exit 1;
}
$releaseVersion = "${{ inputs.release-version }}".Trim().ToLower();
if ($releaseVersion -eq "") {
Write-Host "::error::The 'release-version' workflow input cannot be empty.";
exit 1;
}
$prodVersionRegex = "v[0-9]+\.[0-9]+\.[0-9]+";
$prevVersionRegex = "v[0-9]+\.[0-9]+\.[0-9]+-preview\.[0-9]+";
# Verify that the version has valid syntax
if (($releaseVersion -match $prodVersionRegex) -or ($releaseVersion -match $prevVersionRegex)) {
Write-Host "::notice::The 'release-version' workflow input is valid.";
} else {
$versionSyntax = $releaseType == "production" ? "v#.#.#" : "v#.#.#-preview.#";
Write-Host "::error::The 'release-version' workflow input is not valid. Expected format: '$versionSyntax";
exit 1;
}
prepare_release:
name: Prepare ${{ inputs.release-type }} Release Of ${{ vars.PROJECT_NAME }}
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/prepare-release.yml@v10.0.1
with:
project-name: "${{ vars.PROJECT_NAME }}"
release-type: "${{ inputs.release-type }}"
release-version: "${{ inputs.release-version }}"
secrets:
cicd-pat: ${{ secrets.CICD_TOKEN }}
39 changes: 8 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 🚀Release
run-name: ${{ vars.PROJECT_NAME }} ${{ inputs.release_type }} Release ${{ inputs.dry-run == true && '(Dry Run)' || '' }}
run-name: ${{ vars.PROJECT_NAME }} ${{ inputs.release-type }} Release ${{ inputs.dry-run == true && '(Dry Run)' || '' }}


defaults:
Expand All @@ -10,13 +10,11 @@ defaults:
on:
workflow_dispatch:
inputs:
release_type:
release-type:
description: The type of release. Choose 'Preview' or 'Production'.
required: true
type: choice
options:
- Preview
- Production
options: [Preview, Production]
dry-run:
description: Check to run the workflow without creating a release.
required: false
Expand All @@ -25,44 +23,23 @@ on:


jobs:
determine_build_config:
name: Determine Build Configuration
runs-on: ubuntu-latest
outputs:
build-config: "${{ steps.get-build-config.outputs.build-config }}"
steps:
- name: Get Build Config
id: get-build-config
run: |
# If the branch that the workflow is running on is the required branch for the release, do a release build
if ( "${{ github.base_ref }}" -eq "main") {
"build-config=Release" >> $env:GITHUB_OUTPUT;
echo "Release build created.";
} else { # Any other branch than the release branch, do a debug build
"build-config=Debug" >> $env:GITHUB_OUTPUT;
echo "Debug build created.";
}
run_release:
name: Performing ${{ inputs.release_type }} Release of ${{ vars.PROJECT_NAME }} ${{ inputs.dry-run == true && '(Dry Run)' || '' }}
needs: determine_build_config
uses: KinsonDigital/Infrastructure/.github/workflows/release.yml@v7.2.0
name: Performing ${{ inputs.release-type }} Release of ${{ vars.PROJECT_NAME }} (${{ inputs.release-type == 'Production' && 'Release' || 'Debug' }})
uses: KinsonDigital/Infrastructure/.github/workflows/dotnet-lib-release.yml@v10.0.1
with:
project-name: "${{ vars.PROJECT_NAME}}"
release-type: "${{ inputs.release_type }}"
release-type: "${{ inputs.release-type }}"
run-branch: "${{ github.ref_name }}"
net-sdk-version: "${{ vars.NET_SDK_VERSION }}"
relative-release-notes-dir-path: "${{ vars.RELATIVE_RELEASE_NOTES_DIR_PATH }}"
release-notes-file-name-prefix: "${{ vars.RELEASE_NOTES_FILE_NAME_PREFIX }}"
build-config: "${{ needs.determine_build_config.outputs.build-config }}"
cicd-scripts-version: "${{ vars.CICD_SCRIPTS_VERSION }}"
build-config: ${{ inputs.release-type == 'Production' && 'Release' || 'Debug' }}
pr-include-notes-label: "${{ vars.PR_INCLUDE_NOTES_LABEL }}"
send-release-tweet: ${{ vars.TWITTER_BROADCAST_ENABLED == 'true' }}
dry-run: ${{ inputs.dry-run }}
transpile-readme: true
secrets:
cicd-rest-api: "${{ secrets.CICD_REST_API }}"
cicd-pat: "${{ secrets.CICD_TOKEN }}"
nuget-org-api-key: "${{ secrets.NUGET_ORG_API_KEY }}"
twitter-consumer-api-key: "${{ secrets.TWITTER_CONSUMER_API_KEY }}"
twitter-consumer-api-secret: "${{ secrets.TWITTER_CONSUMER_API_SECRET }}"
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/sonar-scan-pr-status-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ defaults:


on:
workflow_dispatch:
pull_request:
branches:
- main
- release
- preview-release
branches: [main, prod-release, prev-release]


jobs:
sonar_analyze_code:
name: Analyze Code
sonar_status_check:
name: Sonar Status Check
runs-on: ubuntu-latest
steps:
- name: Set up JDK 11
Expand Down Expand Up @@ -61,9 +57,11 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./.sonar/scanner/dotnet-sonarscanner begin /k:"KinsonDigital_Velaptor" /o:"kinsondigital" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
$orgNameLower = "${{ vars.ORGANIZATION_NAME }}".ToLower();
dotnet clean "${{ github.workspace }}/Velaptor/Velaptor.csproj";
dotnet build "${{ github.workspace }}/Velaptor/Velaptor.csproj" -c Debug;
./.sonar/scanner/dotnet-sonarscanner begin /k:"${{ vars.ORGANIZATION_NAME }}_${{ vars.PROJECT_NAME }}" /o:"$orgNameLower" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet clean "${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.csproj";
dotnet build "${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.csproj" -c Debug;
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
19 changes: 10 additions & 9 deletions .github/workflows/sync-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
sync_bot:
name: Sync Bot
name: Sync Bot Status Check
if: ${{ !github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
Expand All @@ -30,24 +30,25 @@ jobs:
$issueNumber = "${{ github.event.issue.number }}";
echo "Project Name: ${{ vars.PROJECT_NAME }}";
echo "Issue: $issueNumber";
Write-Host "::notice::Project Name: ${{ vars.PROJECT_NAME }}";
Write-Host "::notice::Issue: $issueNumber";
if ($manuallyExecuted -and $issueNumber -eq "0") {
echo "The issue or PR number must be a value greater than 0.";
Write-Host "::notice::The issue or PR number must be a value greater than 0.";
exit 1;
}
<# Deno Args:
1. Project Name
2. Issue Number
3. Event Type - set to issue event type
4. GitHub token
1. Organization name
2. Project name
3. Issue number
4. Event Type - set to issue event type
5. PAT
#>
deno run `
--allow-net `
"$scriptUrl" `
"${{ vars.PROJECT_NAME }}" `
"$issueNumber" `
"issue" `
"${{ secrets.CICD_REST_API }}";
"${{ secrets.CICD_TOKEN }}";
34 changes: 19 additions & 15 deletions .github/workflows/sync-issue-to-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
sync_issue_to_pr:
name: Start Sync Process
if: |
github.event_name == 'issue_comment' ||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '[run-sync]')) ||
github.event_name == 'pull_request' && startsWith(github.head_ref, 'feature/')
runs-on: ubuntu-latest
steps:
Expand All @@ -29,23 +29,27 @@ jobs:
- name: Sync
run: |
$eventName = "${{ github.event_name }}";
$scriptUrl = "${{ vars.SCRIPT_BASE_URL }}/${{ vars.CICD_SCRIPTS_VERSION }}/${{ vars.SCRIPT_RELATIVE_DIR_PATH}}/sync-issue-to-pr.ts";
$prNumber = $eventName -eq "pull_request" ? "${{ github.event.number }}" : "${{ github.event.issue.number }}";
$command = $eventName -eq "issue_comment" ? "${{ github.event.comment.body }}" : "[initial-sync]";
$scriptUrl = "${{ vars.SCRIPT_BASE_URL }}/${{ vars.CICD_SCRIPTS_VERSION }}/${{ vars.SCRIPT_RELATIVE_DIR_PATH }}/sync-issue-to-pr.ts";
$issueOrPrNumber = $eventName -eq "pull_request" ? "${{ github.event.number }}" : "${{ github.event.issue.number }}";
echo "Event Name: $eventName";
echo "Organization Name: ${{ vars.ORGANIZATION_NAME }}";
echo "Project Name: ${{ vars.PROJECT_NAME }}";
echo "Requested By: ${{ github.event.sender.login }}";
echo "PR Number: $prNumber";
echo "Comment: $command";
Write-Host "::notice::Event Type: $eventName";
Write-Host "::notice::Organization Name: ${{ vars.ORGANIZATION_NAME }}";
Write-Host "::notice::Project Name: ${{ vars.PROJECT_NAME }}";
Write-Host "::notice::Requested By: ${{ github.event.sender.login }}";
Write-Host "::notice::PR Number: $issueOrPrNumber";
<# Deno Args:
1. Organization name
2. Project name
3. Triggered by user
4. Issue or pull request number
5. PAT
#>
deno run `
--allow-net `
"$scriptUrl" `
"${{ vars.ORGANIZATION_NAME}}" `
"${{ vars.ORGANIZATION_NAME }}" `
"${{ vars.PROJECT_NAME }}" `
"${{ github.event.sender.login }}" `
"$prNumber" `
"$command" `
"${{ secrets.CICD_REST_API }}";
"$issueOrPrNumber" `
"${{ secrets.CICD_TOKEN }}";
Loading

0 comments on commit 4ecec74

Please sign in to comment.