Skip to content

Instantly share code, notes, and snippets.

@rfennell
Last active June 17, 2025 14:45
Show Gist options
  • Save rfennell/c72aa92491dc905da6d4f6cf2d2c5b92 to your computer and use it in GitHub Desktop.
Save rfennell/c72aa92491dc905da6d4f6cf2d2c5b92 to your computer and use it in GitHub Desktop.
A sample GitHub Actions Workflow that provides the same behaviour as the Azure DevOps Pipeline $(rev:r) build name i,e, counts the runs of a named build on the current date
name: Workflow Rev Sample
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# You have to grant the actions read permission else the GH CLI get a 403 error
permissions:
actions: read
contents: read
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Generate Workfloew revsion
shell: powershell
id: get_buildrev
run: |
# Count the runs for the current workflow that were queued today
$date = get-date
$rev=$(gh run list --limit 100 --workflow '${{ github.workflow }}' --json createdAt | jq -r --arg DATE "$($date.ToString('yyyy-MM-d'))" '[.[] | select(.createdAt | startswith($DATE))] | length ')
write-host "Revision: $rev"
"REV=$rev" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Use the run ID
run: echo "The latest run ID is ${{ steps.get_buildrev.outputs.REV }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment