Skip to content

Commit

Permalink
fix(workflow): move create preview comment job to deploy documentatio…
Browse files Browse the repository at this point in the history
…n workflow (#4207)
  • Loading branch information
alionazherdetska authored Dec 12, 2024
1 parent 115909e commit 9759691
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
10 changes: 8 additions & 2 deletions .github/actions/preview/message/create/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ inputs:
access-token:
description: The access token to use for commenting.
required: true
issue-number:
description: The issue number from the caller workflow.
required: true

runs:
using: composite
steps:
- uses: actions/github-script@v7
env:
ISSUE_NUMBER: ${{ inputs.issue-number }}
with:
github-token: ${{ inputs.access-token }}
script: |
const { ISSUE_NUMBER } = process.env
const commentTitle = '**Related Previews**'
const commentInitialBody = 'Preview URLs will be added here, once they are ready... ![loader](https://github.com/swisspost/design-system/assets/9716662/49a75898-7093-4ffb-9460-071ff194459d)'
Expand All @@ -25,7 +31,7 @@ runs:
await github.rest.issues.createComment({
repo: context.repo.repo,
owner: context.repo.owner,
issue_number: context.issue.number,
issue_number: ISSUE_NUMBER,
body: `${commentTitle}\n${commentInitialBody}`
})
Expand All @@ -45,7 +51,7 @@ runs:
comments = (await github.rest.issues.listComments({
repo: context.repo.repo,
owner: context.repo.owner,
issue_number: context.issue.number
issue_number: ISSUE_NUMBER
})).data || []
previewComment = comments.find(c => c.user.login === 'swisspost-bot' && c.body.includes(commentTitle))
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/build-documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Create preview message
uses: ./.github/actions/preview/message/create
with:
access-token: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }}

- name: Setup
uses: ./.github/actions/setup-pnpm

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/deploy-documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ jobs:
name: design-system-documentation
folder: build-output

- name: Create preview message
uses: ./.github/actions/preview/message/create
with:
access-token: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }}
issue-number: ${{ steps.build.outputs.id }}

- name: Get netlify config
id: netlify-config
uses: actions/github-script@v7
Expand Down

0 comments on commit 9759691

Please sign in to comment.