diff --git a/.github/workflows/tugboat-refresh-cache-dispatch.yml b/.github/workflows/tugboat-refresh-cache-dispatch.yml new file mode 100644 index 000000000..f281e1071 --- /dev/null +++ b/.github/workflows/tugboat-refresh-cache-dispatch.yml @@ -0,0 +1,23 @@ + + +name: Refresh Tugboat Preview ID Cache - Dispatch +on: + workflow_dispatch: + inputs: + key: + description: 'Cache key of the entry to be refreshed' + required: false + type: string +jobs: + # Refresh cache for given keys + refresh_cache: + name: Refresh cache for given keys + runs-on: ubuntu-latest + steps: + - name: Refresh Preview ID + uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + with: + path: .tugboat_preview.txt + key: ${{ inputs.key }} + - name: Cleanup temporary file + run: rm .tugboat_preview.txt diff --git a/.github/workflows/tugboat-refresh-cache.yml b/.github/workflows/tugboat-refresh-cache.yml index bd1167fa1..eb4c8d0cd 100644 --- a/.github/workflows/tugboat-refresh-cache.yml +++ b/.github/workflows/tugboat-refresh-cache.yml @@ -7,8 +7,6 @@ jobs: # Collects the cache keys that need to be refreshed collect_cache_keys: name: Collect Tugboat Preview ID cache keys that need to be refreshed - outputs: - matrix: ${{ steps.cache-keys.outputs.result }} runs-on: ubuntu-latest steps: - name: Cross reference open PRs against cache keys in repo @@ -48,27 +46,15 @@ jobs: if (cacheKeys.includes(`${{ runner.os }}-tugboat-preview-id-pr-${pr}`)) { console.log(`Need to refresh: ${pr}`) toRefresh.push(pr) + + await github.rest.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'tugboat-refresh-cache-dispatch.yml', + ref: `refs/pull/${pr}/merge`, + inputs: { + key: `${{ runner.os }}-tugboat-preview-id-pr-${pr}` + }, + }) } } - - const result = JSON.stringify(toRefresh) - console.log(`Refresh Keys: ${result}`) - return result - result-encoding: string - - # Refresh cache for given keys - refresh_cache: - name: Refresh cache for given keys - needs: [ collect_cache_keys ] - runs-on: ubuntu-latest - strategy: - matrix: - value: ${{fromJSON(needs.collect_cache_keys.outputs.matrix)}} - steps: - - name: Refresh Preview ID - uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 - with: - path: .tugboat_preview.txt - key: ${{ runner.os }}-tugboat-preview-id-pr-${{ matrix.value }} - - name: Cleanup temporary file - run: rm .tugboat_preview.txt