Skip to content

Commit bdf2970

Browse files
vaindclaude
andauthored
fix: Use GITHUB_WORKFLOW_REF instead of _workflow_version input (#109)
* chore/danger-workflow-download * Use GITHUB_WORKFLOW_REF instead of _workflow_version input Automatically determines the workflow reference from GITHUB_WORKFLOW_REF instead of requiring manual _workflow_version input parameter. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Update updater workflow to use GITHUB_WORKFLOW_REF Remove _workflow_version input parameter and automatically determine the workflow reference from GITHUB_WORKFLOW_REF instead. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Add changelog entry for GITHUB_WORKFLOW_REF fix 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix(updater): Convert shell commands to PowerShell in workflow checkout step The workflow was failing because it used shell syntax (bash) in a PowerShell context. Converted the shell commands to proper PowerShell equivalents: - Variable assignment using PowerShell syntax - mkdir -> New-Item with -Force flag - cd -> Set-Location - regex replacement using PowerShell -replace operator 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
1 parent 6c79cf7 commit bdf2970

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

.github/workflows/danger-workflow-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88
jobs:
99
danger:
1010
uses: ./.github/workflows/danger.yml
11-
with:
12-
_workflow_version: ${{ github.sha }}
1311

1412
test-outputs:
1513
runs-on: ubuntu-latest

.github/workflows/danger.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# Runs DangerJS with a pre-configured set of rules on a Pull Request.
22
on:
33
workflow_call:
4-
inputs:
5-
_workflow_version:
6-
description: 'Internal: specify github-workflows (this repo) revision to use when checking out scripts.'
7-
type: string
8-
required: false
9-
default: v2 # Note: update when publishing a new version
104
outputs:
115
outcome:
126
description: Whether the Danger run finished successfully. Possible values are success, failure, cancelled, or skipped.
@@ -24,8 +18,10 @@ jobs:
2418

2519
- name: Download dangerfile.js and utilities
2620
run: |
27-
wget https://raw.githubusercontent.com/getsentry/github-workflows/${{ inputs._workflow_version }}/danger/dangerfile.js -P ${{ runner.temp }}
28-
wget https://raw.githubusercontent.com/getsentry/github-workflows/${{ inputs._workflow_version }}/danger/dangerfile-utils.js -P ${{ runner.temp }}
21+
# Extract the ref from GITHUB_WORKFLOW_REF (e.g., getsentry/github-workflows/.github/workflows/danger.yml@refs/pull/109/merge -> refs/pull/109/merge)
22+
WORKFLOW_REF=$(echo "${{ github.workflow_ref }}" | sed 's/.*@//')
23+
wget https://raw.githubusercontent.com/getsentry/github-workflows/${WORKFLOW_REF}/danger/dangerfile.js -P ${{ runner.temp }}
24+
wget https://raw.githubusercontent.com/getsentry/github-workflows/${WORKFLOW_REF}/danger/dangerfile-utils.js -P ${{ runner.temp }}
2925
3026
# Using a pre-built docker image in GitHub container registry instaed of NPM to reduce possible attack vectors.
3127
- name: Run DangerJS

.github/workflows/updater.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ on:
3838
type: string
3939
required: false
4040
default: create
41-
_workflow_version:
42-
description: 'Internal: specify github-workflows (this repo) revision to use when checking out scripts.'
43-
type: string
44-
required: false
45-
default: v2 # Note: update when publishing a new version
4641
secrets:
4742
api-token:
4843
required: true
@@ -141,11 +136,13 @@ jobs:
141136
# Note: cannot use `actions/checkout` at the moment because you can't clone outside of the repo root.
142137
# Follow https://github.com/actions/checkout/issues/197
143138
run: |
144-
mkdir -p ${{ runner.temp }}/ghwf
145-
cd ${{ runner.temp }}/ghwf
139+
# Extract the ref from GITHUB_WORKFLOW_REF (e.g., getsentry/github-workflows/.github/workflows/updater.yml@refs/pull/109/merge -> refs/pull/109/merge)
140+
$workflowRef = '${{ github.workflow_ref }}' -replace '.*@', ''
141+
New-Item -ItemType Directory -Force -Path '${{ runner.temp }}/ghwf'
142+
Set-Location '${{ runner.temp }}/ghwf'
146143
git init
147144
git remote add origin https://github.com/getsentry/github-workflows.git
148-
git fetch --depth 1 origin ${{ inputs._workflow_version }}
145+
git fetch --depth 1 origin $workflowRef
149146
git checkout FETCH_HEAD
150147
151148
- name: Update to the latest version

.github/workflows/workflow-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
name: WORKFLOW-TEST-DEPENDENCY-DO-NOT-MERGE
1313
pattern: '^2\.0\.'
1414
pr-strategy: update
15-
_workflow_version: ${{ github.sha }}
1615
secrets:
1716
api-token: ${{ github.token }}
1817

@@ -23,7 +22,6 @@ jobs:
2322
name: Workflow args test script
2423
runs-on: macos-latest
2524
pattern: '.*'
26-
_workflow_version: ${{ github.sha }}
2725
secrets:
2826
api-token: ${{ github.token }}
2927

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Use GITHUB_WORKFLOW_REF instead of _workflow_version input parameter to automatically determine workflow script versions ([#109](https://github.com/getsentry/github-workflows/pull/109))
8+
39
## 2.14.0
410

511
### Features

0 commit comments

Comments
 (0)