Skip to content

Commit 4400ad7

Browse files
authored
Merge branch 'main' into add-optional-overwrite-input-for-restore
Signed-off-by: Jarek Potiuk <[email protected]>
2 parents dd61c91 + 3762d30 commit 4400ad7

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

stash/restore/action.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ inputs:
2222
functionality as there is no eviction (only expiry).
2323
2424
The action checks the current branch for a stash, if there is no match,
25-
the base branch(PRs)/default branch is searched. If there is more than one
26-
match for any branch the most recently updated stash takes precedent.
25+
the base branch(PRs)/default branch is searched unless it's specified not to.
26+
If there is more than one match for any branch the most recently updated stash takes precedent.
2727
2828
To reduce amount of api calls (1000/h/repo limit) the name of the
2929
current branch will be appended to the key. Key and branchname will be normalized.
@@ -40,6 +40,11 @@ inputs:
4040
description: 'Whether the stash_directory should be removed before downloading the stash.'
4141
default: 'false'
4242

43+
only-current-branch:
44+
description: >
45+
If true, only the current branch will be searched for the stash.
46+
If false, the base branch(PRs)/default branch branch will be searched as well.
47+
default: "false"
4348
outputs:
4449
stash-hit:
4550
description: >
@@ -82,7 +87,7 @@ runs:
8287
m.output_munged_name(output = 'stash_head')
8388
m.output_munged_name(ref = 'base_ref', output = 'stash_base')
8489
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
85-
f.write(f'stash_path={os.path.abspath(os.environ["stash_path"])}' + '\n')
90+
f.write(f'stash_path={os.path.abspath(os.path.expanduser(os.environ["stash_path"]))}' + '\n')
8691
8792
- name: Check for stash artifact
8893
id: check-stash
@@ -98,6 +103,7 @@ runs:
98103
head_name: "${{ steps.mung.outputs.stash_head }}"
99104
run_id: "${{ github.run_id }}"
100105
stash_key: "${{ inputs.key }}"
106+
only_current_branch: "${{ inputs.only-current-branch }}"
101107

102108
shell: python3 {0}
103109
run: |
@@ -116,9 +122,11 @@ runs:
116122
stash = gs.get_branch_stash(repo, head_name, env("head_ref"), env("head_repo_id"))
117123
118124
if not stash:
119-
gs.print_debug(f"Looking for stash {base_name} on base branch.")
120-
stash = gs.get_branch_stash(repo, base_name, env("base_ref"), env("base_repo_id"))
121-
125+
if env("only_current_branch") == "true":
126+
print("Skipping base branch search as only-current-branch was set to true.")
127+
else:
128+
gs.print_debug(f"Looking for stash {base_name} on base branch.")
129+
stash = gs.get_branch_stash(repo, base_name, env("base_ref"), env("base_repo_id"))
122130
gs.print_debug(f"Stash: {stash}")
123131
if not stash:
124132
print(f"Stash not found for key: {env('stash_key')}")

stash/save/action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ inputs:
7575
Default is true to enable updating the stash.
7676
Only applies within a workflow. Existing stashes are unaffected.
7777
default: 'true'
78+
include-hidden-files:
79+
description: >
80+
If true, hidden files will be included in the artifact.
81+
If false, hidden files will be excluded from the artifact.
82+
default: 'false'
7883

7984
outputs:
8085
stash-id:
@@ -115,11 +120,12 @@ runs:
115120
116121
- name: Upload Stash
117122
id: upload
118-
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
123+
uses: actions/upload-artifact@v4
119124
with:
120125
name: ${{ steps.mung.outputs.stash_name }}
121126
path: ${{ inputs.path }}
122127
retention-days: ${{ inputs.retention-days }}
123128
if-no-files-found: ${{ inputs.if-no-files-found }}
124129
compression-level: ${{ inputs.compression-level }}
125130
overwrite: ${{ inputs.overwrite }}
131+
include-hidden-files: ${{ inputs.include-hidden-files }}

0 commit comments

Comments
 (0)