From 6b790f3aaa52c611933ab93608657b88c467eec9 Mon Sep 17 00:00:00 2001 From: Gauthier Fiorentino Date: Thu, 21 Mar 2024 13:40:25 +0100 Subject: [PATCH] CI: Extract publish to its own workflow --- .github/workflows/CD.yml | 26 ++--------------- .github/workflows/publish-package.yml | 42 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/publish-package.yml diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index dd7c2f6..517d8b7 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -37,26 +37,6 @@ jobs: artifact_name: "storybook-latest" publish-package: needs: build - permissions: - packages: write - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup node - uses: actions/setup-node@v4 - with: - # TODO: add version to a .nvmrc or at least a variable - node-version: 18.12.1 - cache: npm - registry-url: 'https://npm.pkg.github.com' - - name: Install - run: npm ci --omit=dev --prefer-offline - - name: Download dist - uses: actions/download-artifact@v4 - with: - name: "lib-latest" - path: "./dist" - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/publish-package.yml + with: + package-name: "lib-latest" diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml new file mode 100644 index 0000000..a941788 --- /dev/null +++ b/.github/workflows/publish-package.yml @@ -0,0 +1,42 @@ +name: 'Publish package' + +on: + workflow_call: + inputs: + artifact-name: + description: name of the artifact to publish + required: true + type: string + workflow_dispatch: + inputs: + artifact-name: + description: name of the artifact to publish + required: false + type: string + default: "lib-latest" + +jobs: + publish-package: + permissions: + packages: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v4 + with: + # TODO: add version to a .nvmrc or at least a variable + node-version: 18.12.1 + cache: npm + registry-url: 'https://npm.pkg.github.com' + - name: Install + run: npm ci --omit=dev --prefer-offline + - name: Download dist + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + path: "./dist" + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}