Skip to content

Commit

Permalink
Update save-cache and restore-cache actions 11/06/2024 | 24w45a3
Browse files Browse the repository at this point in the history
  • Loading branch information
GamesTrap committed Nov 6, 2024
1 parent 4c7f8c4 commit 7ae6376
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions .github/composite/restore-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ runs:
shell: bash
id: check-cache-linux
if: runner.os == 'Linux'
continue-on-error: true
run: |
set +e
sudo apt install -y smbclient
if smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'ls "${{steps.build-dest-path.outputs.TARGET_PATH}}"' 2>/dev/null | grep -q "${{steps.build-dest-path.outputs.TARGET_PATH}}"; then
echo "CACHE_HIT=true" >> "$GITHUB_OUTPUT"
Expand All @@ -44,7 +44,6 @@ runs:
id: check-cache-windows
shell: powershell
if: runner.os == 'Windows'
continue-on-error: true
run: |
New-PSDrive -Name "X" -PSProvider FileSystem -Root "\\${{inputs.server-hostname}}\${{inputs.server-share}}" -Persist -Credential (New-Object System.Management.Automation.PSCredential ("${{inputs.server-username}}", (ConvertTo-SecureString "${{inputs.server-password}}" -AsPlainText -Force)))
if (Test-Path "X:\${{steps.build-dest-path.outputs.TARGET_PATH}}") {
Expand All @@ -56,20 +55,17 @@ runs:
- name: Restore cache (Linux)
shell: bash
if: runner.os == 'Linux' && ${{steps.check-cache-linux.outputs.CACHE_HIT}} == "true"
continue-on-error: true
run: |
sudo apt install -y smbclient
smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'prompt; recurse; get "${{steps.build-dest-path.outputs.TARGET_PATH}}" "${{inputs.key}}.7z"'
- name: Restore cache (Windows)
shell: bash
if: runner.os == 'Windows' && ${{steps.check-cache-windows.outputs.CACHE_HIT}} == "true"
continue-on-error: true
run: |
New-PSDrive -Name "X" -PSProvider FileSystem -Root "\\${{inputs.server-hostname}}\${{inputs.server-share}}" -Persist -Credential (New-Object System.Management.Automation.PSCredential ("${{inputs.server-username}}", (ConvertTo-SecureString "${{inputs.server-password}}" -AsPlainText -Force)))
Copy-Item -Path "X:\${{steps.build-dest-path.outputs.TARGET_PATH}}" -Destination ".\${{inputs.key}}.7z"
Remove-PSDrive -Name "X"
- name: Extract cache (7z)
continue-on-error: true
shell: bash
run: |
7z x -aos -bb0 -bse0 -bsp2 -pdefault -sccUTF-8 -o${{inputs.folder-path}} '${{inputs.key}}.7z'
Expand Down
6 changes: 1 addition & 5 deletions .github/composite/save-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ runs:
shell: bash
id: check-cache-linux
if: runner.os == 'Linux'
continue-on-error: true
run: |
set +e
sudo apt install -y smbclient
if smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'ls "${{steps.build-dest-path.outputs.TARGET_PATH}}"' 2>/dev/null | grep -q "${{steps.build-dest-path.outputs.TARGET_PATH}}"; then
echo "CACHE_HIT=true" >> "$GITHUB_OUTPUT"
Expand All @@ -45,7 +45,6 @@ runs:
id: check-cache-windows
shell: powershell
if: runner.os == 'Windows'
continue-on-error: true
run: |
New-PSDrive -Name "X" -PSProvider FileSystem -Root "\\${{inputs.server-hostname}}\${{inputs.server-share}}" -Persist -Credential (New-Object System.Management.Automation.PSCredential ("${{inputs.server-username}}", (ConvertTo-SecureString "${{inputs.server-password}}" -AsPlainText -Force)))
if (Test-Path "X:\${{steps.build-dest-path.outputs.TARGET_PATH}}") {
Expand All @@ -57,21 +56,18 @@ runs:
- name: Archive cache (7z)
shell: bash
if: ${{steps.check-cache-linux.outputs.CACHE_HIT}} == "false" || ${{steps.check-cache-windows.outputs.CACHE_HIT}} == "false"
continue-on-error: true
run: |
7z a -t7z -m0=LZMA2 -mmt=$(nproc) -mx9 -md=64m -mfb=64 -ms=16g -mqs=on -sccUTF-8 -bb0 -bse0 -bsp2 -w -mtc=on -mta=on '${{inputskey}}.7z' ${{inputs.folder-path}}/*
- name: Upload cache (Windows)
shell: powershell
if: runner.os == 'Windows' && ${{steps.check-cache-windows.outputs.CACHE_HIT}} == "false"
continue-on-error: true
run: |
New-PSDrive -Name "X" -PSProvider FileSystem -Root "\\${{inputs.server-hostname}}\${{inputs.server-share}}" -Persist -Credential (New-Object System.Management.Automation.PSCredential ("${{inputs.server-username}}", (ConvertTo-SecureString "${{inputs.server-password}}" -AsPlainText -Force)))
Copy-Item -Path "${{inputs.key}}.7z" -Destination (New-Item -type directory -force "X:\${{steps.build-dest-path.outputs.TARGET_FOLDER_PATH}}") -force -ea 0
Remove-PSDrive -Name "X"
- name: Upload cache (Linux)
shell: bash
if: runner.os == 'Linux' && ${{steps.check-cache-linux.outputs.CACHE_HIT}} == "false"
continue-on-error: true
run: |
sudo apt install -y smbclient
smbclient //${{inputs.server-hostname}}/${{inputs.server-share}} -U ${{inputs.server-username}}%${{inputs.server-password}} -c 'prompt; recurse; mkdir "${{steps.build-dest-path.outputs.TARGET_FOLDER_PATH}}"; put "${{inputs.key}}.7z" "${{steps.build-dest-path.outputs.TARGET_PATH}}"'
Expand Down

0 comments on commit 7ae6376

Please sign in to comment.