Skip to content

Commit

Permalink
feat: Enable caching, use variables on specified version, and update …
Browse files Browse the repository at this point in the history
…README.md
  • Loading branch information
AnimMouse committed Nov 16, 2023
1 parent 58a61a1 commit 1477503
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
version: [latest, 0.13.1]
version: [latest, "${{ vars.SPECIFIED_VERSION }}"]

steps:
- name: Setup Restic using setup-restic
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ With this action, you can now manipulate your Restic repository like check or pr
To use `restic`, run this action before `restic`.

### Use secrets for repository
1. Paste restic repository to `RESTIC_REPOSITORY` secret.
2. Paste restic repository password to `RESTIC_PASSWORD` secret.
1. Paste Restic repository to `RESTIC_REPOSITORY` secret.
2. Paste Restic repository password to `RESTIC_PASSWORD` secret.

```yaml
steps:
Expand All @@ -27,7 +27,7 @@ steps:
### Use workflow dispatch inputs for repository
1. Add `restic-repository` workflow dispatch input on your workflow.
2. Paste restic repository password to `RESTIC_PASSWORD` secret.
2. Paste Restic repository password to `RESTIC_PASSWORD` secret.

```yaml
on:
Expand All @@ -50,8 +50,8 @@ steps:
```

### Use plain env input for repository
1. Paste restic repository to `RESTIC_REPOSITORY:` environment variable.
2. Paste restic repository password to `RESTIC_PASSWORD` secret.
1. Paste Restic repository to `RESTIC_REPOSITORY:` environment variable.
2. Paste Restic repository password to `RESTIC_PASSWORD` secret.

```yaml
steps:
Expand Down Expand Up @@ -121,7 +121,7 @@ steps:
```

### Specific version
You can specify the version you want. By default, this action downloads the latest version.
You can specify the version you want. By default, this action downloads the latest version if version is not specified.

```yaml
steps:
Expand Down
21 changes: 18 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,23 @@ runs:
version: ${{ inputs.version }}
GITHUB_TOKEN: ${{ inputs.token }}

- name: Restore Restic cache
id: cache
uses: actions/cache/restore@v3
with:
path: ${{ runner.tool_cache }}/Restic
key: Restic-${{ steps.version-unix-like.outputs.version || steps.version-windows.outputs.version }}-${{ runner.os }}

- name: Download Restic for Unix-like
if: runner.os == 'Linux' || runner.os == 'macOS'
if: (runner.os == 'Linux' || runner.os == 'macOS') && ! steps.cache.outputs.cache-hit
shell: bash
working-directory: ${{ runner.temp }}
run: $GITHUB_ACTION_PATH/scripts/download/Unix-like.sh
env:
version: ${{ steps.version-unix-like.outputs.version }}

- name: Download Restic for Windows
if: runner.os == 'Windows'
if: runner.os == 'Windows' && ! steps.cache.outputs.cache-hit
shell: pwsh
working-directory: ${{ runner.temp }}
run: '& $env:GITHUB_ACTION_PATH\scripts\download\Windows.ps1'
Expand All @@ -51,4 +58,12 @@ runs:
- name: Install Restic on tool cache
uses: AnimMouse/tool-cache@v1
with:
folder_name: Restic
folder_name: Restic
cache_hit: ${{ steps.cache.outputs.cache-hit }}

- name: Save Restic cache
if: '! steps.cache.outputs.cache-hit'
uses: actions/cache/save@v3
with:
path: ${{ runner.tool_cache }}/Restic
key: Restic-${{ steps.version-unix-like.outputs.version || steps.version-windows.outputs.version }}-${{ runner.os }}

0 comments on commit 1477503

Please sign in to comment.