Skip to content

Commit

Permalink
add example workflow that updates to latest version the tasks/actions
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Jul 25, 2024
1 parent 1be4fce commit 8db95ed
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/examples-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Update examples version

on:
repository_dispatch:
types: [ update-examples ]

defaults:
run:
shell: pwsh

jobs:
update-examples-version:
if: ${{ github.event_name == 'repository_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PUSH_GITHUB_TOKEN }}
- run: |
$oldTag = "${{ github.event.client_payload.oldTag }}"
$newTag = "${{ github.event.client_payload.newTag }}"
. .\update-version.ps1 # Import the functions
dir -r .github\**\*.yml | % { update-md-files $_ -OldVersion $oldTag -NewVersion $newTag }
dir -r .azure\**\*.yml | % { update-md-files $_ -OldVersion $oldTag -NewVersion $newTag }
git add --verbose .
git config user.name 'Artur Stolear'
git config user.email 'artur.stolear@gmail.com'
git commit -m "update examples version to $newTag" --allow-empty
git push --force
name: Update examples version
20 changes: 20 additions & 0 deletions update-version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function update-md-files()
{
param(
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $true)]
[System.String]
$file,

[Parameter(Mandatory = $True, Position = 1, ValueFromPipeline = $false)]
[System.String]
$oldVersion,

[Parameter(Mandatory = $True, Position = 2, ValueFromPipeline = $false)]
[System.String]
$newVersion
)
$file = Resolve-Path $file
Write-Host "Update md file $file version from $oldVersion to $newVersion"

((Get-Content $file -Raw) -replace $oldVersion, $newVersion) | Set-Content $file -NoNewline
}

0 comments on commit 8db95ed

Please sign in to comment.