Skip to content

Commit

Permalink
ci: update project workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
CalvinWilkinson committed Aug 11, 2023
1 parent 38e6471 commit f48ce35
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 109 deletions.
91 changes: 0 additions & 91 deletions .github/workflows/add-issue-to-project.yml

This file was deleted.

95 changes: 95 additions & 0 deletions .github/workflows/add-item-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Add Issue To Project


defaults:
run:
shell: pwsh


on:
workflow_call:
inputs:
org-name:
description: The name of the organization that owns the project.
required: true
type: string
org-project-name:
description: The name of the organization project to add the issue to.
required: true
type: string
repo-name:
required: true
description: "The name of the C# project to validate."
type: string
item-number:
required: true
description: "The issue or pr number of the item to add to the project."
type: string
secrets:
cicd-pat:
description: The CICD personal access token.
required: true


jobs:
add_issue_to_project:
name: Add Item To Project
runs-on: ubuntu-latest
steps:
- name: Print Environment Variables
run: Get-ChildItem -Path Env:* | Sort-Object Name

- name: Validate Workflow Inputs
run: |
if ("${{ inputs.org-name }}" -eq "") {
Write-Host ":error::The 'org-name' workflow input cannot be empty.";
exit 1;
}
if ("${{ inputs.org-project-name }}" -eq "") {
Write-Host ":error::The 'org-project-name' workflow input cannot be empty.";
exit 1;
}
if ("${{ inputs.repo-name }}" -eq "") {
Write-Host ":error::The 'repo-name' workflow input cannot be empty.";
exit 1;
}
if ("${{ inputs.item-number }}" -eq "") {
Write-Host ":error::The 'item-number' workflow input cannot be empty.";
exit 1;
}
- name: Set Up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Add To Project
run: |
# Construct the URL to the organizations CICD scripts
$scriptUrl = "${{ vars.SCRIPT_BASE_URL }}/${{ vars.CICD_SCRIPTS_VERSION }}/${{ vars.SCRIPT_RELATIVE_DIR_PATH }}";
$scriptUrl = $scriptUrl.Replace("\", "/");
$scriptUrl = $scriptUrl.EndsWith("/") ? $scriptUrl.Substring(0, $scriptUrl.Length - 1) : $scriptUrl;
$scriptUrl = "$scriptUrl/add-item-to-project.ts";
Write-Host "::notice::NuGet Package Check Script URL: $scriptUrl";
<# Deno Args:
1. Organization name
2. Project name
3. Repo name
4. Issue or PR number
5. PAT
#>
deno run `
--allow-net `
"$scriptUrl" `
"${{ inputs.org-name }}" `
"${{ inputs.org-project-name }}" `
"${{ inputs.repo-name }}" `
"${{ inputs.item-number }}" `
"${{ secrets.cicd-pat }}";
18 changes: 0 additions & 18 deletions .github/workflows/add-new-issue-to-project.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/add-new-item-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 🤖Add New Issue To Project


defaults:
run:
shell: pwsh


on:
issues:
types: opened
pull_request:
types: opened
branches: main


jobs:
item_number:
name: Get Item Number
runs-on: ubuntu-latest
outputs:
item-number: ${{ steps.get-item-number.outputs.item-number }}
steps:
- name: Get Item Number
id: get-item-number
run: |
$eventName = "${{ github.event_name }}";
$itemNumber = $eventName -eq "issues" ? "${{ github.event.issue.number }}" : "${{ github.event.pull_request.number }}";
$itemType = $eventName -eq "issues" ? "issue" : "pull request";
Write-Host "::notice::Invoked by $itemType '$itemNumber'";
"item-number=$itemNumber" >> $env:GITHUB_OUTPUT;
add_new_issue_to_project:
name: Add New Issue
needs: item_number
uses: KinsonDigital/Infrastructure/.github/workflows/[email protected]
with:
org-name: "${{ vars.ORGANIZATION_NAME }}"
org-project-name: "${{ vars.ORG_PROJECT_NAME }}"
repo-name: "${{ vars.PROJECT_NAME }}"
item-number: "${{ needs.item_number.outputs.item-number }}"
secrets:
cicd-pat: ${{ secrets.CICD_TOKEN }}

0 comments on commit f48ce35

Please sign in to comment.