Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add reusable workflow for upload and download build artifacts in actions #2000

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/actions/download-builds/action.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you wrote in the PR's description: "Call the reusable action of download-builds instead the previous yarn lerna run build ... step"
Are we cool with that happening also for the lint steps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it is happening in like 2-3s so we're cool with it

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Download and Extract Build Artifacts
description: Download build artifacts for all the packages and extract them to the correct location

runs:
using: "composite"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this action is composite and the second one isn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the build and upload can be a job of its own (reusable workflow)
reusable action is a step that encapsulates multiple steps
reusable workflow is a job that encapsulates multiple jobs

the reason I chose going with a reusable workflow for the build-and-upload is that in case we need the build, I'm saving the consumer from doing checkout and setup. the consumer can just do:

  build:
    name: Build
    uses: ./.github/workflows/build-and-upload.yml
    secrets:
      npm_token: ${{ secrets.npm_token }}

if the build-and-upload was a reusable action (composite), it would have looked like this:

  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Run Setup
        uses: ./.github/actions/setup
        with:
          npm_token: ${{secrets.npm_token}}
      - name: Run Build
        shell: bash
        run: yarn lerna run build --since=origin/master --include-dependencies

in probably 100% of the cases where consumers would need the build, they would just want it to happen, they don't need to interfere what happens with it

steps:
- name: Download and Extract
uses: actions/download-artifact@v4
with:
name: ci-builds-${{ github.run_id }}-${{ github.run_attempt }}
path: packages/
30 changes: 30 additions & 0 deletions .github/workflows/build-and-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and Upload Artifacts

on:
workflow_call:
secrets:
npm_token:
required: true

jobs:
build-and-upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Setup
uses: ./.github/actions/setup
with:
npm_token: ${{ secrets.npm_token }}
- name: Build
shell: bash
run: yarn lerna run build --since=origin/master --include-dependencies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is relevant only for branches that aren't master, maybe we can emphasis it somehow so no one will use it for master?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep :)
#2006 does exactly that and I will update all of our workflows once it is merged, including this new build-and-upload workflow

- name: Upload
uses: actions/upload-artifact@v4
with:
name: ci-builds-${{ github.run_id }}-${{ github.run_attempt }}
path: |
packages/core/dist/
packages/style/dist/
if-no-files-found: ignore