Skip to content

Commit

Permalink
get run-id for cross workflow stashes
Browse files Browse the repository at this point in the history
  • Loading branch information
assignUser committed Feb 19, 2024
1 parent a84d40f commit fc8fd6f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions restore/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ runs:
| .name // empty' res.json)
if [ -z "$stash_name" ]; then
echo "stash_exists=true" >> $GITHUB_OUTPUT
echo "stash_name=$stash_name" >> $GITHUB_OUTPUT
echo "stash_exists=true" >> $GITHUB_ENV
echo "stash_name=$stash_name" >> $GITHUB_ENV
else
echo "stash_exists=false" >> $GITHUB_OUTPUT
fi
Expand All @@ -54,14 +54,15 @@ runs:
-f name=${{ inputs.key }} \
--method=get \
/repos/${{ github.repository }}/actions/artifacts > res.json
# todo filter for base and current branch
jq '.artifacts
| map(select(.name | test ("${{ inputs.key }}")))
| max_by(.updated_at)' res.json > stash.json
stash_name=$(jq '.artifacts
| map(select(.name | test ("${{ inputs.key }}")))
| max_by(.updated_at)
| .name // empty' res.json)
stash_name=$(jq '.artifacts[0].name // empty' stash.json)
if [ -z "$stash_name" ]; then
echo "stash_name=$stash_name" >> $GITHUB_OUTPUT
echo "stash_name=$stash_name" >> $GITHUB_ENV
echo "stash_run_id=$(jq '.artifacts[0].workflow_run.id')" >> $GITHUB_ENV
else
exit 1
fi
Expand All @@ -71,6 +72,7 @@ runs:
GH_TOKEN: ${{ inputs.token }}
uses: actions/download-artifact@v4
with:
name: ${{ steps.check-stash.outputs.stash_name || inputs.key }}
name: ${{ env.stash_name || inputs.key }}
path: ${{ inputs.path }}
token: ${{ inputs.token }}
github-token: ${{ inputs.token }}
run-id: ${{ env.stash_id }}

0 comments on commit fc8fd6f

Please sign in to comment.