diff --git a/.github/workflows/danger-workflow-tests.yml b/.github/workflows/danger-workflow-tests.yml index 0b27a3a1..dd9877a1 100644 --- a/.github/workflows/danger-workflow-tests.yml +++ b/.github/workflows/danger-workflow-tests.yml @@ -8,8 +8,6 @@ on: jobs: danger: uses: ./.github/workflows/danger.yml - with: - _workflow_version: ${{ github.sha }} test-outputs: runs-on: ubuntu-latest diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index c2e3931b..6cdf7159 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -1,12 +1,6 @@ # Runs DangerJS with a pre-configured set of rules on a Pull Request. on: workflow_call: - inputs: - _workflow_version: - description: 'Internal: specify github-workflows (this repo) revision to use when checking out scripts.' - type: string - required: false - default: v2 # Note: update when publishing a new version outputs: outcome: description: Whether the Danger run finished successfully. Possible values are success, failure, cancelled, or skipped. @@ -24,8 +18,10 @@ jobs: - name: Download dangerfile.js and utilities run: | - wget https://raw.githubusercontent.com/getsentry/github-workflows/${{ inputs._workflow_version }}/danger/dangerfile.js -P ${{ runner.temp }} - wget https://raw.githubusercontent.com/getsentry/github-workflows/${{ inputs._workflow_version }}/danger/dangerfile-utils.js -P ${{ runner.temp }} + # Extract the ref from GITHUB_WORKFLOW_REF (e.g., getsentry/github-workflows/.github/workflows/danger.yml@refs/pull/109/merge -> refs/pull/109/merge) + WORKFLOW_REF=$(echo "${{ github.workflow_ref }}" | sed 's/.*@//') + wget https://raw.githubusercontent.com/getsentry/github-workflows/${WORKFLOW_REF}/danger/dangerfile.js -P ${{ runner.temp }} + wget https://raw.githubusercontent.com/getsentry/github-workflows/${WORKFLOW_REF}/danger/dangerfile-utils.js -P ${{ runner.temp }} # Using a pre-built docker image in GitHub container registry instaed of NPM to reduce possible attack vectors. - name: Run DangerJS diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index e98a257f..dfe349bc 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -38,11 +38,6 @@ on: type: string required: false default: create - _workflow_version: - description: 'Internal: specify github-workflows (this repo) revision to use when checking out scripts.' - type: string - required: false - default: v2 # Note: update when publishing a new version secrets: api-token: required: true @@ -141,11 +136,13 @@ jobs: # Note: cannot use `actions/checkout` at the moment because you can't clone outside of the repo root. # Follow https://github.com/actions/checkout/issues/197 run: | - mkdir -p ${{ runner.temp }}/ghwf - cd ${{ runner.temp }}/ghwf + # Extract the ref from GITHUB_WORKFLOW_REF (e.g., getsentry/github-workflows/.github/workflows/updater.yml@refs/pull/109/merge -> refs/pull/109/merge) + $workflowRef = '${{ github.workflow_ref }}' -replace '.*@', '' + New-Item -ItemType Directory -Force -Path '${{ runner.temp }}/ghwf' + Set-Location '${{ runner.temp }}/ghwf' git init git remote add origin https://github.com/getsentry/github-workflows.git - git fetch --depth 1 origin ${{ inputs._workflow_version }} + git fetch --depth 1 origin $workflowRef git checkout FETCH_HEAD - name: Update to the latest version diff --git a/.github/workflows/workflow-tests.yml b/.github/workflows/workflow-tests.yml index aeeb351b..da019473 100644 --- a/.github/workflows/workflow-tests.yml +++ b/.github/workflows/workflow-tests.yml @@ -12,7 +12,6 @@ jobs: name: WORKFLOW-TEST-DEPENDENCY-DO-NOT-MERGE pattern: '^2\.0\.' pr-strategy: update - _workflow_version: ${{ github.sha }} secrets: api-token: ${{ github.token }} @@ -23,7 +22,6 @@ jobs: name: Workflow args test script runs-on: macos-latest pattern: '.*' - _workflow_version: ${{ github.sha }} secrets: api-token: ${{ github.token }} diff --git a/CHANGELOG.md b/CHANGELOG.md index ed4b44cd..2fb48ba1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- 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)) + ## 2.14.0 ### Features