From f41534c430109c750be4f2ea1e125df3846986a2 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Fri, 16 Feb 2024 14:10:06 +0000 Subject: [PATCH] Fix: Add missing `Content-Type` key in `Invoke-RestMethod -Headers` Fixes Powershell 7.4 which now expects either `Invoke-RestMethod -Headers @{ 'Content-type' = '...' }` or `-ContentType` to be populated, or it would error with `The given key 'Content-Type' was not present in the dictionary.`. See: - https://github.com/theohbrothers/docker-kubectl/actions/runs/7909389274/job/21590330176#step:3:1516 - https://github.com/theohbrothers/docker-terraform/actions/runs/7837925330/job/21388510328#step:3:636 --- .../public/Automerge-DockerImageVariantsPR.ps1 | 1 + src/Generate-DockerImageVariantsHelpers/public/New-Release.ps1 | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Generate-DockerImageVariantsHelpers/public/Automerge-DockerImageVariantsPR.ps1 b/src/Generate-DockerImageVariantsHelpers/public/Automerge-DockerImageVariantsPR.ps1 index 4bd3f7d..b268161 100644 --- a/src/Generate-DockerImageVariantsHelpers/public/Automerge-DockerImageVariantsPR.ps1 +++ b/src/Generate-DockerImageVariantsHelpers/public/Automerge-DockerImageVariantsPR.ps1 @@ -17,6 +17,7 @@ function Automerge-DockerImageVariantsPR { 'Accept' = 'application/vnd.github+json' 'Authorization' = "Bearer $env:GITHUB_TOKEN" 'X-GitHub-Api-Version' = '2022-11-28' + 'Content-Type' = 'application/json' } "Will automerge PR" | Write-Host if (!$WhatIfPreference) { diff --git a/src/Generate-DockerImageVariantsHelpers/public/New-Release.ps1 b/src/Generate-DockerImageVariantsHelpers/public/New-Release.ps1 index 598d3c0..1f346da 100644 --- a/src/Generate-DockerImageVariantsHelpers/public/New-Release.ps1 +++ b/src/Generate-DockerImageVariantsHelpers/public/New-Release.ps1 @@ -19,6 +19,7 @@ function New-Release { 'Accept' = 'application/vnd.github+json' 'Authorization' = "Bearer $env:GITHUB_TOKEN" 'X-GitHub-Api-Version' = '2022-11-28' + 'Content-Type' = 'application/json' } $owner = ({ git remote get-url origin } | Execute-Command) -replace 'https://github.com/([^/]+)/([^/]+)', '$1' $project = ({ git remote get-url origin } | Execute-Command) -replace 'https://github.com/([^/]+)/([^/]+)', '$2' -replace '\.git$', ''