From b76255b0d0edf179a8bb632a4604e22fd5d66cef Mon Sep 17 00:00:00 2001 From: Tudor Popa Date: Thu, 22 Sep 2022 18:00:14 +0200 Subject: [PATCH] feat(cicd): add reusable build action, enable remote build caching, update all actions to use the new action Update .github/actions/build-to/action.yml Co-authored-by: Martin Hochel --- .github/actions/build-to/action.yml | 35 +++++++++++++++++++ .../workflows/docsite-publish-chromatic.yml | 5 ++- .github/workflows/docsite-publish-ghpages.yml | 5 ++- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 .github/actions/build-to/action.yml diff --git a/.github/actions/build-to/action.yml b/.github/actions/build-to/action.yml new file mode 100644 index 0000000000000..d9ad0d14d64d3 --- /dev/null +++ b/.github/actions/build-to/action.yml @@ -0,0 +1,35 @@ +name: 'Build workspaces' +description: 'Runs the build command for specific workspaces.' +inputs: + # Because Github Actions doesn't support arrays as inputs we need to pass the workspaces as a string and split them + # by spaces https://github.com/community/community/discussions/11692 + workspaces: + required: true + description: 'The workspaces you want to build. This parameter accepts multiple workspaces separated by a space.' + # This is based on the backfill cache provider options: https://github.com/microsoft/backfill#set-up-remote-cache + backfill-cache-provider: + required: false + description: 'The backfill cache provider' + default: 'azure-blob' + # Depending on the chosen cache provider there are multiple types of available options. In our case we use Azure Blob + # Storage. https://github.com/microsoft/backfill#microsoft-azure-blob-storage + backfill-cache-provider-options: + required: false + description: 'The backfill cache provider options' + # Flag to toggle backfill remote caching on / off + lage-write-remote-cache: + required: true + description: 'Whether to write to the remote cache' + default: 'true' + +runs: + using: 'composite' + steps: + - name: build package dependency tree (scripts:build) + working-directory: . + shell: bash + run: yarn build --to ${{ inputs.workspaces }} + env: + BACKFILL_CACHE_PROVIDER: ${{ inputs.backfill-cache-provider }} + BACKFILL_CACHE_PROVIDER_OPTIONS: ${{ inputs.backfill-cache-provider-options }} + LAGE_WRITE_REMOTE_CACHE: ${{ inputs.lage-write-remote-cache }} diff --git a/.github/workflows/docsite-publish-chromatic.yml b/.github/workflows/docsite-publish-chromatic.yml index f06e6d9e6301b..2369a9478b303 100644 --- a/.github/workflows/docsite-publish-chromatic.yml +++ b/.github/workflows/docsite-publish-chromatic.yml @@ -44,7 +44,10 @@ jobs: run: yarn install --frozen-lockfile - name: Build dependencies - run: yarn build --to @fluentui/public-docsite-v9 + uses: ./.github/actions/build-to + with: + workspaces: '@fluentui/public-docsite-v9' + backfill-cache-provider-options: ${{ secrets.BACKFILL_CACHE_PROVIDER_OPTIONS }} - name: Publish to Chromatic run: yarn workspace @fluentui/public-docsite-v9 chromatic diff --git a/.github/workflows/docsite-publish-ghpages.yml b/.github/workflows/docsite-publish-ghpages.yml index 5663c4f45f15a..fa9e24a32e514 100644 --- a/.github/workflows/docsite-publish-ghpages.yml +++ b/.github/workflows/docsite-publish-ghpages.yml @@ -44,7 +44,10 @@ jobs: run: yarn install --frozen-lockfile - name: Build dependencies - run: yarn build --to @fluentui/public-docsite-v9 + uses: ./.github/actions/build-to + with: + workspaces: '@fluentui/public-docsite-v9' + backfill-cache-provider-options: ${{ secrets.BACKFILL_CACHE_PROVIDER_OPTIONS }} - name: Build storybook run: yarn workspace @fluentui/public-docsite-v9 build-storybook