Skip to content

Commit

Permalink
chore: test update
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschuerch committed May 2, 2024
1 parent b0a0da3 commit 1040c70
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 32 deletions.
42 changes: 42 additions & 0 deletions .github/actions/preview/message/create/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Preview message creation
description: Append a preview url message in the pr body, if not already present

inputs:
access-token:
description: The access token to use for commenting.
required: true

runs:
using: composite
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ inputs.access-token }}
script: |
const commentTitle = '**Related Previews**'
const credentials = {
repo: context.repo.repo,
owner: context.repo.owner,
issue_number: context.issue.number
}
const comments = (await github.rest.issues.listComments({ ...credentials })).data || []
const hasPreviewComment = comments.some(c => c.user.login === 'swisspost-bot' && c.body.includes(commentTitle))
if (!hasPreviewComment) {
github.rest.issues.createComment({
...credentials,
body: `${commentTitle}\nPreview URLs will be added here, once they are ready... ![loader](https://github.com/swisspost/design-system/assets/9716662/49a75898-7093-4ffb-9460-071ff194459d)`
})
} else {
const previewComment = comments.find(c => c.user.login === 'swisspost-bot' && c.body.includes(commentTitle))
console.log(body);
console.log('-------------');
const body = previewComment.body
.replace('\nPreview URLs will be added here, once they are ready... ![loader](https://github.com/swisspost/design-system/assets/9716662/49a75898-7093-4ffb-9460-071ff194459d)', '')
.concat('- previewurl')
console.log('-------------');
console.log(body);
}
30 changes: 0 additions & 30 deletions .github/actions/preview/message/creation/action.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/build-documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

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

Expand Down

0 comments on commit 1040c70

Please sign in to comment.