From fa371f486c1e2f463ce21a24dcdbf20eeb77aeae Mon Sep 17 00:00:00 2001 From: Frank Dana Date: Tue, 3 Oct 2023 19:47:46 -0400 Subject: [PATCH 1/2] Workflow commands: Minor tweaks to example formatting, syntax (#28767) --- .../workflow-commands-for-github-actions.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/content/actions/using-workflows/workflow-commands-for-github-actions.md b/content/actions/using-workflows/workflow-commands-for-github-actions.md index aad853f1a594..ce9fb62b3307 100644 --- a/content/actions/using-workflows/workflow-commands-for-github-actions.md +++ b/content/actions/using-workflows/workflow-commands-for-github-actions.md @@ -104,10 +104,10 @@ You can use the `set-output` command in your workflow to set the same value: ```yaml copy - name: Set selected color run: echo '::set-output name=SELECTED_COLOR::green' - id: random-color-generator + id: color-selector - name: Get color {% raw %} - run: echo "The selected color is ${{ steps.random-color-generator.outputs.SELECTED_COLOR }}" + run: echo "The selected color is ${{ steps.color-selector.outputs.SELECTED_COLOR }}" {% endraw %} ``` @@ -118,10 +118,10 @@ You can use the `set-output` command in your workflow to set the same value: ```yaml copy - name: Set selected color run: Write-Output "::set-output name=SELECTED_COLOR::green" - id: random-color-generator + id: color-selector - name: Get color {% raw %} - run: Write-Output "The selected color is ${{ steps.random-color-generator.outputs.SELECTED_COLOR }}" + run: Write-Output "The selected color is ${{ steps.color-selector.outputs.SELECTED_COLOR }}" {% endraw %} ``` @@ -509,8 +509,8 @@ jobs: GENERATED_SECRET=$((RANDOM)) echo "::add-mask::$GENERATED_SECRET" SECRET_HANDLE=$(secret-store store-secret "$GENERATED_SECRET"){% ifversion actions-save-state-set-output-envs %} - echo "handle=$secret_handle" >> "$GITHUB_OUTPUT"{% else %} - echo "::set-output name=handle::$secret_handle"{% endif %} + echo "handle=$SECRET_HANDLE" >> "$GITHUB_OUTPUT"{% else %} + echo "::set-output name=handle::$SECRET_HANDLE"{% endif %} secret-consumer: runs-on: macos-latest needs: secret-generator @@ -921,11 +921,11 @@ This example demonstrates how to set the `SELECTED_COLOR` output parameter and l ```yaml copy - name: Set color - id: random-color-generator + id: color-selector run: echo "SELECTED_COLOR=green" >> "$GITHUB_OUTPUT" - name: Get color env:{% raw %} - SELECTED_COLOR: ${{ steps.random-color-generator.outputs.SELECTED_COLOR }}{% endraw %} + SELECTED_COLOR: ${{ steps.color-selector.outputs.SELECTED_COLOR }}{% endraw %} run: echo "The selected color is $SELECTED_COLOR" ``` @@ -937,12 +937,12 @@ This example demonstrates how to set the `SELECTED_COLOR` output parameter and l ```yaml copy - name: Set color - id: random-color-generator + id: color-selector run: | "SELECTED_COLOR=green" | Out-File -FilePath $env:GITHUB_OUTPUT -Append - name: Get color -        env:{% raw %} -          SELECTED_COLOR: ${{ steps.random-color-generator.outputs.SELECTED_COLOR }}{% endraw %} + env:{% raw %} + SELECTED_COLOR: ${{ steps.color-selector.outputs.SELECTED_COLOR }}{% endraw %} run: Write-Output "The selected color is $env:SELECTED_COLOR" ``` From 3c7e291cd9ef1829c6dd9c81c7718f30091facc3 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Wed, 4 Oct 2023 01:09:00 +0100 Subject: [PATCH 2/2] Improve example workflow to delete cache entries for closed PRs (#27618) Co-authored-by: Sarah Edwards --- .../caching-dependencies-to-speed-up-workflows.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/content/actions/using-workflows/caching-dependencies-to-speed-up-workflows.md b/content/actions/using-workflows/caching-dependencies-to-speed-up-workflows.md index 708aff00624a..ec563bd0e172 100644 --- a/content/actions/using-workflows/caching-dependencies-to-speed-up-workflows.md +++ b/content/actions/using-workflows/caching-dependencies-to-speed-up-workflows.md @@ -344,17 +344,11 @@ on: jobs: cleanup: runs-on: ubuntu-latest - steps: - - name: Check out code - uses: {% data reusables.actions.action-checkout %} - + steps: - name: Cleanup run: | gh extension install actions/gh-actions-cache - REPO={% raw %}${{ github.repository }}{% endraw %} - BRANCH="refs/pull/{% raw %}${{ github.event.pull_request.number }}{% endraw %}/merge" - echo "Fetching list of cache key" cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) @@ -368,6 +362,8 @@ jobs: echo "Done" env: GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} + REPO: {% raw %}${{ github.repository }}{% endraw %} + BRANCH: refs/pull/{% raw %}${{ github.event.pull_request.number }}{% endraw %}/merge ``` Alternatively, you can use the API to automatically list or delete all caches on your own cadence. For more information, see "[AUTOTITLE](/rest/actions/cache#about-the-cache-in-github-actions)."