diff --git a/.github/actions/preview-message-creation/action.yaml b/.github/actions/preview-message-creation/action.yaml deleted file mode 100644 index 7cd0598619..0000000000 --- a/.github/actions/preview-message-creation/action.yaml +++ /dev/null @@ -1,31 +0,0 @@ -### -# -# used action https://github.com/marketplace/actions/github-script -# -### - -name: Preview message creation -description: Append a preview url message in the pr body, if not already present - -runs: - using: composite - steps: - - uses: actions/github-script@v7 - with: - script: | - const credentials = { - pull_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo - } - - const pr = await github.rest.pulls.get(credentials) - - const body = pr.data.body || '' - - if (!body.includes('Automatic previews')) { - github.rest.pulls.update({ - ...credentials, - body: `**Automatic previews**\n\nPreview URLs will be added here, once they are ready... ![loader](https://github.com/swisspost/design-system/assets/9716662/f067a322-e6bd-4fed-b9d5-ff924d6254c2)` - }) - } diff --git a/.github/actions/preview/message/creation/action.yaml b/.github/actions/preview/message/creation/action.yaml new file mode 100644 index 0000000000..7bd3477b0f --- /dev/null +++ b/.github/actions/preview/message/creation/action.yaml @@ -0,0 +1,32 @@ +### +# +# used action https://github.com/marketplace/actions/github-script +# +### + +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 credentials = { + repo: context.repo.repo, + owner: context.repo.owner, + issue_number: context.issue.number + } + + const comments = await github.rest.issues.listComments({ + ...credentials + }) + + console.log(comments) diff --git a/.github/workflows/build-documentation.yaml b/.github/workflows/build-documentation.yaml index 1be33b7e35..7187d99e1c 100644 --- a/.github/workflows/build-documentation.yaml +++ b/.github/workflows/build-documentation.yaml @@ -22,12 +22,14 @@ jobs: runs-on: ubuntu-latest steps: - - name: Provide preview message - uses: swisspost/design-system/.github/actions/preview-message-creation - - name: Checkout uses: actions/checkout@v4 + - name: Provide preview message + uses: ./.github/actions/preview/message/creation + with: + access-token: ${{ secrets.SWISSPOSTDEVS_ACCESS_TOKEN }} + - name: Setup uses: swisspost/design-system/.github/actions/setup-pnpm@main