Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧Various improvements #159

Merged
merged 10 commits into from
Aug 31, 2023
7 changes: 5 additions & 2 deletions .github/internal-cicd/update-workflow-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ if (!Directory.Exists(baseDirPath)) {
Deno.exit(0);
}

// Clear the console so the token is not visible from the tasks.json file
console.clear();

const tagRegex = /v[0-9]+\.[0-9]+\.[0-9]+/gm;

const newVersion = await Input.prompt({
message: chalk.blue("What is your name?"),
message: chalk.blue("Enter version to upgrade workflows to:"),
hint: "Use a tag with the syntax 'v#.#.#'.",
minLength: 5,
validate: (value) => {
Expand All @@ -49,7 +52,7 @@ const allTags = (await tagClient.getAllTags(repoName)).map((t) => t.name);

// If the new tag already exists, throw an error
if (allTags.includes(newVersion)) {
chalk.red(`Tag '${newVersion}' already exists.`);
console.log(chalk.red(`Tag '${newVersion}' already exists.`));
Deno.exit(0);
}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/add-new-item-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
add_new_item_to_project:
name: Add New Issue
needs: item_number
uses: KinsonDigital/Infrastructure/.github/workflows/add-item-to-project.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/add-item-to-project.yml@v13.0.0
with:
org-name: "${{ vars.ORGANIZATION_NAME }}"
org-project-name: "${{ vars.ORG_PROJECT_NAME }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-csharp-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
resolve_proj_file_path:
name: Resolving ${{ inputs.project-name }} Project File Path
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.0.0
with:
project-name: ${{ inputs.project-name }}
base-path: ${{ inputs.base-path }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/dotnet-action-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
validate_version:
name: Validate Version
needs: [print_validate_workflow, validate_branch]
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand All @@ -168,7 +168,7 @@ jobs:
validate_tag:
name: Validate Tag
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand Down Expand Up @@ -207,7 +207,7 @@ jobs:
validate_github_release:
name: GitHub Release Does Not Exist
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -218,7 +218,7 @@ jobs:
build_project:
name: Build Main Project (${{ inputs.project-name }})
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}"
runs-on: "${{ inputs.runs-on }}"
Expand All @@ -229,7 +229,7 @@ jobs:
run_tests:
name: Run Tests
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}Tests"
runs-on: "${{ inputs.runs-on }}"
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/dotnet-lib-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:

validate_version:
name: Validate Version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-csharp-version.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand All @@ -193,7 +193,7 @@ jobs:
validate_tag:
name: Validate Tag
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-tag.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}"
release-type: "${{ inputs.release-type }}"
Expand All @@ -205,7 +205,7 @@ jobs:
nuget_pkg_does_not_exist:
name: Validate NuGet Package Does Not Exist
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/nuget-package-does-not-exist.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/nuget-package-does-not-exist.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -214,7 +214,7 @@ jobs:
validate_milestone_status:
name: Validate Milestone Status
needs: validate_version
uses: KinsonDigital/Infrastructure/.github/workflows/validate-milestone-status.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-milestone-status.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -225,7 +225,7 @@ jobs:
validate_github_release:
name: GitHub Release Does Not Exist
needs: [validate_version]
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/validate-github-release.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}"
version: "${{ needs.validate_version.outputs.version }}"
Expand All @@ -236,7 +236,7 @@ jobs:
build_project:
name: Build Main Project
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}"
runs-on: "${{ inputs.runs-on }}"
Expand All @@ -247,7 +247,7 @@ jobs:
run_tests:
name: Run Tests
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v13.0.0
with:
project-name: "${{ inputs.project-name }}Tests"
runs-on: "${{ inputs.runs-on }}"
Expand Down
112 changes: 112 additions & 0 deletions .github/workflows/initial-manual-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: 🔄️Sync PR To Issue
run-name: 🔄️Sync PR To Issue (${{ inputs.sync-type }})


defaults:
run:
shell: pwsh


on:
workflow_call:
inputs:
issue-or-pr-number:
description: Issue or pr number
required: true
type: number
sync-type:
description: Type of sync to perform. ("manual" or "initial")
required: true
type: string
requested-by: # User can be prefixed with 'validate:'
description: User who requested the sync
required: true
type: string
branch:
description: Name of branch. (Only required for initial sync)
required: false
type: string
secrets:
cicd-pat:
required: true
description: The CICD personal access token.


jobs:
sync_issue_to_pr:
name: Start Sync Process
runs-on: ubuntu-latest
steps:
- name: Validate Sync Type
run: |
$syncType = "${{ inputs.sync-type }}";
$validSyncType = $syncType -in "manual", "initial";

if ($validSyncType -eq $false) {
$msg = "The sync type `${{ inputs.sync-type }}` is not valid. Valid sync types are 'manual' or 'initial'.";
$msg += " Verify that the 'sync-type' input is correct.";
Write-Host "::error::$msg";
exit 1;
}

- name: Check For Skipping
id: skip-checking
run: |
$isManualSync = "${{ inputs.sync-type == 'manual' && contains(github.event.comment.body, '[run-sync]') }}";
$isInitialSync = "${{ inputs.sync-type == 'initial'}}";

$stepOutput = "skip=false";

if ($isManualSync -eq "true") {
Write-Host "::notice::The '[run-sync]' command has been invoked.";
} elseif ($isInitialSync -eq "true") {
$branch = "${{ inputs.branch }}";
$branchRegEx = "${{ vars.FEATURE_BRANCH_REGEX }}";
$isValidBranch = $branch -match $branchRegEx;

if ($isValidBranch -eq $true) {
Write-Host "::notice::The PR has been opened from a valid branch.";
} else {
$msg = "::warning::The branch `${{ inputs.branch }}` does not match the regex `${{ vars.FEATURE_BRANCH_REGEX }}`.";
$msg += " Verify that the 'FEATURE_BRANCH_REGEX' org or repo variable is set correctly.";
Write-Host $msg;
}
} else {
Write-Host "::warning::Issue/PR Sync Process Skipped. Possibly sync command was not exactly '[run-sync]' or incorrect PR head branch.";
$stepOutput = "skip=true";
}

"$stepOutput" >> $env:GITHUB_OUTPUT;

- name: Set Up Deno
if: ${{ steps.skip-checking.outputs.skip == 'false' }}
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Run Sync
if: ${{ steps.skip-checking.outputs.skip == 'false' }}
run: |
$scriptUrl = "${{ vars.SCRIPT_BASE_URL }}/${{ vars.CICD_SCRIPTS_VERSION }}/${{ vars.SCRIPT_RELATIVE_DIR_PATH }}/sync-pr-to-issue.ts";

Write-Host "::notice::Sync Type: ${{ inputs.sync-type }}";
Write-Host "::notice::Organization Name: ${{ vars.ORGANIZATION_NAME }}";
Write-Host "::notice::Project Name: ${{ vars.PROJECT_NAME }}";
Write-Host "::notice::Requested By: ${{ inputs.requested-by }}";
Write-Host "::notice::PR Number: ${{ inputs.issue-or-pr-number }}";

<# Deno Args:
1. Organization name
2. Project name
3. User requesting sync
4. Issue or pull request number
5. PAT
#>
deno run `
--allow-net `
"$scriptUrl" `
"${{ vars.ORGANIZATION_NAME }}" `
"${{ vars.PROJECT_NAME }}" `
"${{ inputs.requested-by }}" `
"${{ inputs.issue-or-pr-number }}" `
"${{ secrets.cicd-pat }}";
2 changes: 1 addition & 1 deletion .github/workflows/run-csharp-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
resolve_proj_file_path:
name: Resolving ${{ inputs.project-name }} Project File Path
needs: print_validate_workflow
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v12.1.1
uses: KinsonDigital/Infrastructure/.github/workflows/resolve-csharp-proj-file.yml@v13.0.0
with:
project-name: ${{ inputs.project-name }}
base-path: ${{ inputs.base-path }}
Expand Down
55 changes: 0 additions & 55 deletions .github/workflows/sync-issue-to-pr.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/sync-pr-to-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 🔄️Sync PR To Issue


defaults:
run:
shell: pwsh


on:
pull_request_target:
types: opened
issue_comment: # This event is triggered when creating issue and pr comments
types: created


jobs:
initial_sync:
name: Start Initial Sync
if: ${{ github.event_name == 'pull_request_target' }}
uses: KinsonDigital/Infrastructure/.github/workflows/[email protected]
with:
issue-or-pr-number: ${{ github.event.pull_request.number }}
sync-type: initial
requested-by: ${{ github.event.sender.login }}
branch: ${{ github.event.pull_request.head.ref }} # Input not required for initial sync
secrets:
cicd-pat: ${{ secrets.CICD_TOKEN }}


manual_sync:
name: Start Manual Sync
if: ${{ github.event_name == 'issue_comment' && contains(github.event.comment.body, '[run-sync]') }}
uses: KinsonDigital/Infrastructure/.github/workflows/[email protected]
with:
issue-or-pr-number: ${{ github.event.issue.number }}
sync-type: manual
requested-by: "validate:${{ github.event.sender.login }}"
secrets:
cicd-pat: ${{ secrets.CICD_TOKEN }}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
"name": "Sync Issue To PR",
"request": "launch",
"type": "node",
"program": "${workspaceFolder}/cicd/scripts/sync-issue-to-pr.ts",
"program": "${workspaceFolder}/cicd/scripts/sync-pr-to-issue.ts",
"cwd": "${workspaceFolder}/cicd",
"runtimeArgs": [
"run",
Expand Down
Loading
Loading