Skip to content

Commit

Permalink
🚧Create add to proj workflow (#241)
Browse files Browse the repository at this point in the history
* Start work for issue #239

* feat: create add proj workflow

* ci: update workflow to reusable workflow

* pr-changes: change workflow version from v8.2.0 to v9.1.0

* pr-changes: update token ref

* pr-changes: update `echo` to `Write-Host`

* pr-changes: update token ref and `echo` to `Write-Host`

* ci: improve status checks

* ci: improve sync system workflows

* ci: improve release workflow

* ci: create prepare release workflow

* ci: update renovate config branch

* ci: update token references

---------

Co-authored-by: Calvin Wilkinson <[email protected]>
Co-authored-by: Calvin Wilkinson <[email protected]>
  • Loading branch information
3 people authored Jul 18, 2023
1 parent f49a1de commit 3f69915
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 139 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/add-new--issue-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 🤖Add New Issue To Project


on:
issues:
types: opened


jobs:
add_new_issue_to_project:
name: Add New Issue
uses: KinsonDigital/Infrastructure/.github/workflows/[email protected]
with:
org-name: "${{ vars.ORGANIZATION_NAME }}"
org-project-name: "${{ vars.ORG_PROJECT_NAME }}"
project-name: "${{ vars.PROJECT_NAME }}"
secrets:
cicd-pat: ${{ secrets.CICD_TOKEN }}
41 changes: 0 additions & 41 deletions .github/workflows/build-pr-status-check.yml

This file was deleted.

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


defaults:
run:
shell: pwsh


on:
workflow_dispatch:
pull_request:
branches: [main, preview]


jobs:
build_status_check:
name: ${{ vars.PROJECT_NAME }} Build Status Check
uses: KinsonDigital/Infrastructure/.github/workflows/[email protected]
with:
project-name: "${{ vars.PROJECT_NAME }}"
build-config: Debug
net-sdk-version: "${{ vars.NET_SDK_VERSION }}"
79 changes: 79 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: 🚁Prepare Release


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:
validate_inputs:
name: Validate Inputs
runs-on: ubuntu-latest
steps:
- name: Validating Inputs
run: |
$projectName = "${{ vars.PROJECT_NAME }}";
$releaseType = "${{ inputs.release-type }}".ToLower();
$releaseVersion = "${{ inputs.release-version }}";
if ($projectName -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;
}
if ($releaseVersion -eq "") {
Write-Host "::error::The release version 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 (($version -match $prodVersionRegex) -or ($version -match $prevVersionRegex)) {
Write-Host "::notice::The version is valid.";
} else {
$versionSyntax = $releaseType == "production" ? "v#.#.#" : "v#.#.#-preview.#";
Write-Host "::error::The version is not valid.\nThe version format is: '$versionSyntax";
exit 1;
}
prepare_release:
name: Prepare ${{ inputs.release-type }} Release Of ${{ vars.PROJECT_NAME }}
uses: KinsonDigital/Infrastructure/.github/workflows/[email protected]
with:
project-name: ${{ vars.PROJECT_NAME }}
release-type: ${{ inputs.release-type }}
release-version: ${{ inputs.release-version }}
secrets:
cicd-pat: ${{ secrets.CICD_TOKEN }}
38 changes: 8 additions & 30 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,24 @@ 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/[email protected]
name: Performing ${{ inputs.release-type }} Release of ${{ vars.PROJECT_NAME }} (${{ inputs.release-type == 'Production' && 'Release' || 'Debug' }})
uses: KinsonDigital/Infrastructure/.github/workflows/[email protected]
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 }}"
build-config: ${{ inputs.release-type == 'Production' && 'Release' || 'Debug' }}
cicd-scripts-version: "${{ vars.CICD_SCRIPTS_VERSION }}"
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
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 }}";
24 changes: 16 additions & 8 deletions .github/workflows/sync-issue-to-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ jobs:
$prNumber = $eventName -eq "pull_request" ? "${{ github.event.number }}" : "${{ github.event.issue.number }}";
$command = $eventName -eq "issue_comment" ? "${{ github.event.comment.body }}" : "[initial-sync]";
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 Name: $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: $prNumber";
Write-Host "::notice:Comment: $command";
<# Deno Args:
1. Organization name
2. Project name
3. Sync request by
4. Pull request number
5. Command - '[initial-sync]' or '[run-sync]'
6. PAT
#>
deno run `
--allow-net `
"$scriptUrl" `
Expand All @@ -48,4 +56,4 @@ jobs:
"${{ github.event.sender.login }}" `
"$prNumber" `
"$command" `
"${{ secrets.CICD_REST_API }}";
"${{ secrets.CICD_TOKEN }}";
20 changes: 11 additions & 9 deletions .github/workflows/sync-status-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,27 @@ jobs:
$scriptUrl = "${{ vars.SCRIPT_BASE_URL }}/${{ vars.CICD_SCRIPTS_VERSION }}/${{ vars.SCRIPT_RELATIVE_DIR_PATH}}/sync-bot-status-check.ts";
$prNumber = "${{ github.event.number }}";
echo "Project Name: ${{ vars.PROJECT_NAME }}";
echo "PR Number: $prNumber";
echo "Event Type: pr";
Write-Host "::notice:Project Name: ${{ vars.PROJECT_NAME }}";
Write-Host "::notice:PR Number: $prNumber";
Write-Host "::notice:Event Type: pr";
if ($manuallyExecuted -and $prNumber -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. PR Number
3. Event Type - set to pull request event type
4. GitHub token
1. Organization name
2. Project name
3. Pull request number
4. Event Type - set to pull request event type
5. PAT
#>
deno run `
--allow-net `
"$scriptUrl" `
"${{ vars.ORGANIZATION_NAME }}" `
"${{ vars.PROJECT_NAME }}" `
"$prNumber" `
"pr" `
"${{ secrets.CICD_REST_API }}";
"${{ secrets.CICD_TOKEN }}";
41 changes: 0 additions & 41 deletions .github/workflows/unit-test-pr-status-check.yml

This file was deleted.

Loading

0 comments on commit 3f69915

Please sign in to comment.