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 8761620 commit 4c7f8c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion .github/composite/restore-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ runs:
shell: bash
id: check-cache-linux
if: runner.os == 'Linux'
continue-on-error: true
run: |
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 || true | grep -q "${{steps.build-dest-path.outputs.TARGET_PATH}}"; then
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"
else
echo "CACHE_HIT=false" >> "$GITHUB_OUTPUT"
Expand All @@ -43,6 +44,7 @@ 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 @@ -54,17 +56,20 @@ 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
7 changes: 6 additions & 1 deletion .github/composite/save-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ runs:
shell: bash
id: check-cache-linux
if: runner.os == 'Linux'
continue-on-error: true
run: |
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 || true | grep -q "${{steps.build-dest-path.outputs.TARGET_PATH}}"; then
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"
else
echo "CACHE_HIT=false" >> "$GITHUB_OUTPUT"
Expand All @@ -44,6 +45,7 @@ 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 @@ -55,18 +57,21 @@ 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 4c7f8c4

Please sign in to comment.