Skip to content

Commit

Permalink
Updated 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 3b82bfd commit 08fc744
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .github/composite/restore-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runs:
echo "TARGET_PATH=${{ github.event.repository.name }}/cache/${{inputs.key}}.7z" >> "$GITHUB_OUTPUT"
- name: Check cache (Linux)
shell: bash
id: check-cache
id: check-cache-linux
if: runner.os == 'Linux'
run: |
sudo apt install -y smbclient
Expand All @@ -40,7 +40,7 @@ runs:
echo "CACHE_HIT=false" >> "$GITHUB_OUTPUT"
fi
- name: Check cache (Windows)
id: check-cache
id: check-cache-windows
shell: powershell
if: runner.os == 'Windows'
run: |
Expand All @@ -53,13 +53,13 @@ runs:
Remove-PSDrive -Name "X"
- name: Restore cache (Linux)
shell: bash
if: runner.os == 'Linux' && ${{steps.check-cache.outputs.CACHE_HIT}} == "true"
if: runner.os == 'Linux' && ${{steps.check-cache-linux.outputs.CACHE_HIT}} == "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.outputs.CACHE_HIT}} == "true"
if: runner.os == 'Windows' && ${{steps.check-cache-windows.outputs.CACHE_HIT}} == "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"
Expand Down
10 changes: 5 additions & 5 deletions .github/composite/save-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:
echo "TARGET_FOLDER_PATH=${{ github.event.repository.name }}/cache" >> "$GITHUB_OUTPUT"
- name: Check cache (Linux)
shell: bash
id: check-cache
id: check-cache-linux
if: runner.os == 'Linux'
run: |
sudo apt install -y smbclient
Expand All @@ -41,7 +41,7 @@ runs:
echo "CACHE_HIT=false" >> "$GITHUB_OUTPUT"
fi
- name: Check cache (Windows)
id: check-cache
id: check-cache-windows
shell: powershell
if: runner.os == 'Windows'
run: |
Expand All @@ -54,19 +54,19 @@ runs:
Remove-PSDrive -Name "X"
- name: Archive cache (7z)
shell: bash
if: ${{steps.check-cache.outputs.CACHE_HIT}} == "false"
if: ${{steps.check-cache-linux.outputs.CACHE_HIT}} == "false" || ${{steps.check-cache-windows.outputs.CACHE_HIT}} == "false"
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.outputs.CACHE_HIT}} == "false"
if: runner.os == 'Windows' && ${{steps.check-cache-windows.outputs.CACHE_HIT}} == "false"
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.outputs.CACHE_HIT}} == "false"
if: runner.os == 'Linux' && ${{steps.check-cache-linux.outputs.CACHE_HIT}} == "false"
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 08fc744

Please sign in to comment.