Skip to content

Commit de1041e

Browse files
author
James Brundage
committed
1 parent 88f8313 commit de1041e

2 files changed

Lines changed: 75 additions & 32 deletions

File tree

.github/workflows/IrregularTests.yml

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -379,32 +379,34 @@ jobs:
379379
380380
if ($releaseExists) {
381381
"::warning::Release '$($releaseExists.Name )' Already Exists" | Out-Host
382-
return
382+
$releasedIt = $releaseExists
383+
} else {
384+
$releasedIt = Invoke-RestMethod -Uri $releasesURL -Method Post -Body (
385+
[Ordered]@{
386+
owner = '${{github.owner}}'
387+
repo = '${{github.repository}}'
388+
tag_name = $targetVersion
389+
name = $ExecutionContext.InvokeCommand.ExpandString($ReleaseNameFormat)
390+
body =
391+
if ($env:RELEASENOTES) {
392+
$env:RELEASENOTES
393+
} elseif ($imported.PrivateData.PSData.ReleaseNotes) {
394+
$imported.PrivateData.PSData.ReleaseNotes
395+
} else {
396+
"$($imported.Name) $targetVersion"
397+
}
398+
draft = if ($env:RELEASEISDRAFT) { [bool]::Parse($env:RELEASEISDRAFT) } else { $false }
399+
prerelease = if ($env:PRERELEASE) { [bool]::Parse($env:PRERELEASE) } else { $false }
400+
} | ConvertTo-Json
401+
) -Headers @{
402+
"Accept" = "application/vnd.github.v3+json"
403+
"Content-type" = "application/json"
404+
"Authorization" = 'Bearer ${{ secrets.GITHUB_TOKEN }}'
405+
}
383406
}
384407
385408
386-
$releasedIt = Invoke-RestMethod -Uri $releasesURL -Method Post -Body (
387-
[Ordered]@{
388-
owner = '${{github.owner}}'
389-
repo = '${{github.repository}}'
390-
tag_name = $targetVersion
391-
name = $ExecutionContext.InvokeCommand.ExpandString($ReleaseNameFormat)
392-
body =
393-
if ($env:RELEASENOTES) {
394-
$env:RELEASENOTES
395-
} elseif ($imported.PrivateData.PSData.ReleaseNotes) {
396-
$imported.PrivateData.PSData.ReleaseNotes
397-
} else {
398-
"$($imported.Name) $targetVersion"
399-
}
400-
draft = if ($env:RELEASEISDRAFT) { [bool]::Parse($env:RELEASEISDRAFT) } else { $false }
401-
prerelease = if ($env:PRERELEASE) { [bool]::Parse($env:PRERELEASE) } else { $false }
402-
} | ConvertTo-Json
403-
) -Headers @{
404-
"Accept" = "application/vnd.github.v3+json"
405-
"Content-type" = "application/json"
406-
"Authorization" = 'Bearer ${{ secrets.GITHUB_TOKEN }}'
407-
}
409+
408410
409411
410412
if (-not $releasedIt) {
@@ -439,10 +441,9 @@ jobs:
439441
$fileBytes = [IO.File]::ReadAllBytes($file.FullName)
440442
$releasedFiles[$file.Name] =
441443
Invoke-RestMethod -Uri "${releaseUploadUrl}?name=$($file.Name)" -Headers @{
442-
"Accept" = "application/vnd.github+json"
443-
"ContentType" = "application/octet-stream"
444+
"Accept" = "application/vnd.github+json"
444445
"Authorization" = 'Bearer ${{ secrets.GITHUB_TOKEN }}'
445-
} -Body $fileBytes
446+
} -Body $fileBytes -ContentType Application/octet-stream
446447
$releasedFiles[$file.Name]
447448
}
448449
}
@@ -583,6 +584,44 @@ jobs:
583584
uses: StartAutomating/EZOut@master
584585
- name: UseHelpOut
585586
uses: StartAutomating/HelpOut@master
587+
- name: Log in to ghcr.io
588+
uses: docker/login-action@master
589+
with:
590+
registry: ${{ env.REGISTRY }}
591+
username: ${{ github.actor }}
592+
password: ${{ secrets.GITHUB_TOKEN }}
593+
- name: Extract Docker Metadata (for branch)
594+
if: ${{github.ref_name != 'main' && github.ref_name != 'master' && github.ref_name != 'latest'}}
595+
id: meta
596+
uses: docker/metadata-action@master
597+
with:
598+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
599+
- name: Extract Docker Metadata (for main)
600+
if: ${{github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'latest'}}
601+
id: metaMain
602+
uses: docker/metadata-action@master
603+
with:
604+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
605+
flavor: latest=true
606+
- name: Build and push Docker image (from main)
607+
if: ${{github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'latest'}}
608+
uses: docker/build-push-action@master
609+
with:
610+
context: .
611+
push: true
612+
tags: ${{ steps.metaMain.outputs.tags }}
613+
labels: ${{ steps.metaMain.outputs.labels }}
614+
- name: Build and push Docker image (from branch)
615+
if: ${{github.ref_name != 'main' && github.ref_name != 'master' && github.ref_name != 'latest'}}
616+
uses: docker/build-push-action@master
617+
with:
618+
context: .
619+
push: true
620+
tags: ${{ steps.meta.outputs.tags }}
621+
labels: ${{ steps.meta.outputs.labels }}
586622
on:
587623
push:
588624
workflow_dispatch:
625+
env:
626+
REGISTRY: ghcr.io
627+
IMAGE_NAME: ${{ github.repository }}

Irregular.GitHubWorkflow.PSDevops.ps1

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
Push-Location $PSScriptRoot
33

44
Import-BuildStep -ModuleName Irregular
5-
New-GitHubWorkflow -Name "Test, Tag, Release, and Publish" -Job PowerShellStaticAnalysis, TestPowerShellOnLinux, TagReleaseAndPublish, BuildIrregular -On Push, Demand |
6-
Set-Content .\.github\workflows\IrregularTests.yml -Encoding UTF8 -PassThru
5+
New-GitHubWorkflow -Name "Test, Tag, Release, and Publish" -Job PowerShellStaticAnalysis,
6+
TestPowerShellOnLinux,
7+
TagReleaseAndPublish,
8+
BuildIrregular -On Push, Demand -Environment ([Ordered]@{
9+
REGISTRY = 'ghcr.io'
10+
IMAGE_NAME = '${{ github.repository }}'
11+
}) -OutputPath .\.github\workflows\IrregularTests.yml
712

8-
New-GitHubWorkflow -Name "Run GitHub Action" -On Push, Demand -Job UseIrregularAction |
9-
Set-Content .\.github\workflows\RunIrregularAction.yml -Encoding UTF8 -PassThru
13+
New-GitHubWorkflow -Name "Run GitHub Action" -On Push,
14+
Demand -Job UseIrregularAction -OutputPath .\.github\workflows\RunIrregularAction.yml
1015

11-
New-GitHubWorkflow -On Issue, Demand -Job RunGitPub -Name OnIssueChanged |
12-
Set-Content (Join-Path $PSScriptRoot .github\workflows\OnIssue.yml) -Encoding UTF8 -PassThru
16+
New-GitHubWorkflow -On Demand -Job RunGitPub -Name "GitPub" -OutputPath .\.github\workflows\RunGitPub.yml
1317

1418

1519
Pop-Location

0 commit comments

Comments
 (0)