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

chore: update GHA deprecations #48

Merged
merged 5 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions .github/workflows/updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@a40b8845c0683271d9f53dfcb887a7e181d3918b # Tag: 0.9.1
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # Tag: 0.11.0
with:
access_token: ${{ github.token }}

Expand Down Expand Up @@ -128,19 +128,18 @@ jobs:
id: root
run: |
$mainBranch = $(git remote show origin | Select-String "HEAD branch: (.*)").Matches[0].Groups[1].Value
Write-Host '::echo::on'
Write-Host "::set-output name=baseBranch::$mainBranch"
$prBranch = switch ('${{ inputs.pr-strategy }}')
{
'create' { 'deps/${{ inputs.path }}/${{ steps.target.outputs.latestTag }}' }
'update' { 'deps/${{ inputs.path }}' }
default { throw "Unkown PR strategy '${{ inputs.pr-strategy }}'." }
}
Write-Host "::set-output name=prBranch::$prBranch"
"baseBranch=$mainBranch" | Tee-Object $env:GITHUB_OUTPUT -Append
"prBranch=$prBranch" | Tee-Object $env:GITHUB_OUTPUT -Append

- name: Fetch an existing PR
if: steps.target.outputs.latestTag != steps.target.outputs.originalTag
uses: octokit/request-action@971ad48f9c40ed001c41c2671b1e6e8e8165d5af
uses: octokit/request-action@89a1754fe82ca777b044ca8e79e9881a42f15a93 # v2.1.7
id: existing-pr-request
with:
route: GET /repos/${{ github.repository }}/pulls?base={base}&head={head}
Expand All @@ -159,15 +158,14 @@ jobs:

$prCount = $($data | jq '. | length')

Write-Host '::echo::on'
if ($prCount -eq '0')
{
Write-Host "::set-output name=url::"
"url=" | Tee-Object $env:GITHUB_OUTPUT -Append
}
elseif ($prCount -eq '1')
{
$url = $($data | Select-String '"html_url": +"(.*/pull/.*)"').Matches[0].Groups[1].Value
Write-Host "::set-output name=url::$url"
"url=$url" | Tee-Object $env:GITHUB_OUTPUT -Append
}
else
{
Expand All @@ -189,7 +187,7 @@ jobs:
# First we create a PR only if it doesn't exist. We will later overwrite the content with the same action.
- name: Create a PR
if: ${{ ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.existing-pr.outputs.url == '') }}
uses: peter-evans/create-pull-request@f22a7da129c901513876a2380e2dae9f8e145330
uses: peter-evans/create-pull-request@b4d51739f96fca8047ad065eccef63442d8e99f7 # pin#v4
id: create-pr
with:
base: ${{ steps.root.outputs.baseBranch }}
Expand All @@ -209,14 +207,13 @@ jobs:
if: steps.target.outputs.latestTag != steps.target.outputs.originalTag
id: pr
run: |
Write-Host '::echo::on'
if ('${{ steps.create-pr.outputs.pull-request-url }}' -ne '')
{
Write-Host "::set-output name=url::${{ steps.create-pr.outputs.pull-request-url }}"
"url=${{ steps.create-pr.outputs.pull-request-url }}" | Tee-Object $env:GITHUB_OUTPUT -Append
}
elseif ('${{ steps.existing-pr.outputs.url }}' -ne '')
{
Write-Host "::set-output name=url::${{ steps.existing-pr.outputs.url }}"
"url=${{ steps.existing-pr.outputs.url }}" | Tee-Object $env:GITHUB_OUTPUT -Append
}
else
{
Expand Down Expand Up @@ -253,7 +250,7 @@ jobs:
# Now make the PR in its final state. This way we only have one commit and no updates if there are no changes between runs.
- name: Update the PR
if: steps.target.outputs.latestTag != steps.target.outputs.originalTag
uses: peter-evans/create-pull-request@f22a7da129c901513876a2380e2dae9f8e145330
uses: peter-evans/create-pull-request@b4d51739f96fca8047ad065eccef63442d8e99f7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 🚫 Please pin the action by specifying a commit SHA instead of a tag/branch.

with:
base: ${{ steps.root.outputs.baseBranch }}
branch: ${{ steps.root.outputs.prBranch }}
Expand Down
11 changes: 5 additions & 6 deletions updater/scripts/update-dependency.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,11 @@ if ("$Tag" -eq "")
$latestTag = $tags[-1]
$latestTagNice = ($latestTag -match "^[0-9]") ? "v$latestTag" : $latestTag

Write-Host '::echo::on'
Write-Host "::set-output name=originalTag::$originalTag"
Write-Host "::set-output name=latestTag::$latestTag"
Write-Host "::set-output name=latestTagNice::$latestTagNice"
Write-Host "::set-output name=url::$url"
Write-Host "::set-output name=mainBranch::$mainBranch"
"originalTag=$originalTag" | Tee-Object $env:GITHUB_OUTPUT -Append
"latestTag=$latestTag" | Tee-Object $env:GITHUB_OUTPUT -Append
"latestTagNice=$latestTagNice" | Tee-Object $env:GITHUB_OUTPUT -Append
"url=$url" | Tee-Object $env:GITHUB_OUTPUT -Append
"mainBranch=$mainBranch" | Tee-Object $env:GITHUB_OUTPUT -Append

if ("$originalTag" -eq "$latestTag")
{
Expand Down