Skip to content

Provide docs on how to cache plugins and policy packs in GitHub Actions workflows #17026

@justinvp

Description

@justinvp

Document how to use actions/cache to cache Pulumi plugins and policy packs to improve subsequent CI times.

For example, a workflow like this:

name: Pulumi Preview (Manual)

on:
  workflow_dispatch:

jobs:
  preview:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repo
        uses: actions/checkout@v6

      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: "3.13"

      - name: Set up Node
        uses: actions/setup-node@v4
        with:
          node-version: "24.x"

      - name: Export HOME for cache paths
        shell: bash
        run: echo "HOME=$HOME" >> $GITHUB_ENV

      - name: Export ImageVersion
        shell: bash
        run: echo "IMAGE_VERSION=$ImageVersion" >> "$GITHUB_ENV"

      - name: Export Python version
        shell: bash
        run: echo "PYTHON_VERSION=$(python3 --version | cut -d' ' -f2)" >> $GITHUB_ENV

      - name: Export Node version
        shell: bash
        run: echo "NODE_VERSION=$(node --version | sed 's/^v//')" >> $GITHUB_ENV

      - name: Cache Pulumi Plugins
        uses: actions/cache@v4
        with:
          path: ${{ env.HOME }}/.pulumi/policies
          key: pulumi-plugins-${{ runner.os }}-${{ runner.arch }}-${{ env.IMAGE_VERSION }}-py${{ env.PYTHON_VERSION }}-node${{ env.NODE_VERSION }}

      - name: Cache Pulumi Policies
        uses: actions/cache@v4
        with:
          path: ${{ env.HOME }}/.pulumi/policies
          key: pulumi-policies-${{ runner.os }}-${{ runner.arch }}-${{ env.IMAGE_VERSION }}-py${{ env.PYTHON_VERSION }}-node${{ env.NODE_VERSION }}

      - name: Pulumi Preview
        uses: pulumi/actions@v6
        with:
          command: preview
          stack-name: ${{ vars.PULUMI_STACK }}
        env:
          PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}

Metadata

Metadata

Assignees

Labels

area/docsImprovements or additions to documentationkind/enhancementImprovements or new features

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions