Skip to content

Commit

Permalink
Merge pull request #130521 from carlocab/gh-try-download
Browse files Browse the repository at this point in the history
workflows: use `gh-try-download` action
  • Loading branch information
carlocab committed May 9, 2023
2 parents 2a6feef + b37077f commit 8f0a4f9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ jobs:
approved: ${{ steps.approval-status.outputs.approved }}
complete: ${{ steps.approval-status.outputs.complete }}
mergeable: ${{ steps.approval-status.outputs.mergeable }}
env:
WORKFLOW_ID: ${{ github.event.workflow_run.id }}
permissions:
contents: read
pull-requests: read
actions: read
steps:
- name: Download `pull-number` artifact
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh run download --name pull-number "$WORKFLOW_ID"
uses: Homebrew/actions/gh-try-download@master
with:
artifact-name: pull-number
workflow-id: ${{ github.event.workflow_run.id }}

- name: Dump debug info in case of failure
if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_ID: ${{ github.event.workflow_run.id }}
run: |
printf '```\n' >> "$GITHUB_STEP_SUMMARY"
gh run view "$WORKFLOW_ID" | tee -a "$GITHUB_STEP_SUMMARY"
Expand All @@ -57,6 +57,10 @@ jobs:
gh api "repos/{owner}/{repo}/actions/runs/$WORKFLOW_ID" | jq . | tee -a "$GITHUB_STEP_SUMMARY"
printf '```\n' >> "$GITHUB_STEP_SUMMARY"
printf '```\n' >> "$GITHUB_STEP_SUMMARY"
gh api "repos/{owner}/{repo}/actions/runs/$WORKFLOW_ID/artifacts" | jq . | tee -a "$GITHUB_STEP_SUMMARY"
printf '```\n' >> "$GITHUB_STEP_SUMMARY"
- run: echo "number=$(cat number)" >> "$GITHUB_OUTPUT"
id: pr

Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/recreate-linux-runners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,22 @@ jobs:
actions: read # for `gh run download`
pull-requests: read # for `gh api`
steps:
- name: Download `pull-number` artifact
if: github.event_name == 'workflow_run'
uses: Homebrew/actions/gh-try-download@master
with:
artifact-name: pull-number
workflow-id: ${{ github.event.workflow_run.id }}

- name: Check if runner needs to be recreated
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_ID: ${{ github.event.workflow_run.id }}
run: |
recreate=true
if [[ "$GITHUB_EVENT_NAME" = "workflow_run" ]]
then
gh run download --name pull-number "$WORKFLOW_ID"
PR="$(cat number)"
recreate="$(
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/remove-long-timeout-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
pull-requests: read # for `gh api`
steps:
- name: Download `pull-number` artifact
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_ID: ${{ github.event.workflow_run.id }}
run: gh run download --name pull-number "$WORKFLOW_ID"
uses: Homebrew/actions/gh-try-download@master
with:
artifact-name: pull-number
workflow-id: ${{ github.event.workflow_run.id }}

- run: echo "number=$(cat number)" >> "$GITHUB_OUTPUT"
id: pr
Expand Down

0 comments on commit 8f0a4f9

Please sign in to comment.