Skip to content

Commit

Permalink
fix: hsec-tools retrieval cache key computations mismatch in GitHub A…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
blackheaven committed Mar 16, 2024
1 parent 50339f3 commit 7e560fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/call-nix.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: nix build
on:
workflow_call:
inputs:
cache-key:
required: true
type: string
jobs:
check_nix:
name: Check nix build
Expand All @@ -21,14 +25,9 @@ jobs:
run: nix build -L '.#packages.x86_64-linux.hsec-tools-image'
- run: mkdir -p ~/.local/dockerImages
- run: cp result ~/.local/dockerImages/hsec-tools
- id: code-hash
name: Compute code directory hash
run: |
code_hash=$(git rev-parse HEAD:code)
echo "code-hash=$code_hash" >> "$GITHUB_OUTPUT"
- uses: actions/cache/save@v3
with:
key: hsec-tools-${{ steps.code-hash.outputs.code-hash}}
key: ${{ inputs.cache-key }}
path: ~/.local/dockerImages
- name: upload executable
uses: actions/upload-artifact@v3
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/check-advisories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ jobs:
run: |
code_hash=$(git rev-parse HEAD:code)
echo "code-hash=$code_hash" >> "$GITHUB_OUTPUT"
populate_cache:
name: Populate cache
uses: ./.github/workflows/call-nix.yml
with:
cache-key: hsec-tools-${{ needs.code_hash.outputs.code_hash }}
check_advisories:
name: Invoke check-advisories workflow
needs: [tools_changed, advisories_changed, code_hash]
needs: [tools_changed, advisories_changed, code_hash, populate_cache]
if: ${{ needs.tools_changed.outputs.should_skip == 'true' && needs.advisories_changed.outputs.should_skip != 'true' }}
uses: ./.github/workflows/call-check-advisories.yml
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
needs: tools-changed
if: ${{ needs.tools_changed.outputs.should_skip != 'true' }}
uses: ./.github/workflows/call-nix.yml
with:
cache-key: hsec-tools-${{ github.sha }}
check-advisories:
name: Invoke check-advisories workflow
if: ${{ needs.tools_changed.outputs.should_skip != 'true' }}
Expand Down

0 comments on commit 7e560fb

Please sign in to comment.