1
0

Parse the event.json of an action (e.g. push)

This commit is contained in:
2026-04-09 20:28:39 +02:00
commit d1ddfe37aa
2 changed files with 69 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
name: 'parse-event'
description: 'Parses a JSON file, that contains all information about the last event.'
outputs:
base-commit:
description: 'The hash of the base commit of the event. This is the commit that was previously at the head of the branch before the event.'
value: ${{ steps.parse.outputs.hash }}
fetch-depth:
description: 'The number of commits needed to get the whole diff of the event.'
value: ${{ steps.parse.outputs.count }}
runs:
using: 'composite'
steps:
- name: Parse event
id: parse
shell: powershell
run: |
chcp 65001 > $null
$event = Get-Content "${{ github.event_path }}" | ConvertFrom-Json
$serverUrl = "${{ github.server_url }}"
$host = $serverUrl -replace '.*://', ''
Write-Output "OUT: hash=$($event.before)"
Write-Output "hash=$($event.before)" | Add-Content -Path $env:GITHUB_OUTPUT
Write-Output "OUT: count=$($event.commits.Count + 1)"
Write-Output "count=$($event.commits.Count + 1)" | Add-Content -Path $env:GITHUB_OUTPUT
Write-Output "ENV: CI_SERVER_HOST=$host"
Write-Output "CI_SERVER_HOST=$host" | Add-Content -Path $env:GITHUB_ENV