# Preview publish package

<figure><img src="https://694473604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOzA1rSlMPE3i2X5tlqgu%2Fuploads%2FZCdzczA729HO2CsFnhUE%2Fimage.png?alt=media&#x26;token=3373666c-de2d-4ae5-985d-8c0be1fbeadd" alt="" width="200"><figcaption><p>exile.watch</p></figcaption></figure>

{% hint style="info" %}
This page covers [`preview-publish-package*`](https://github.com/exile-watch/doryani/blob/main/preview-publish-package/action.yml)actions
{% endhint %}

## Usage

In `.github/workflows/preview-publish-package.yml` paste following snippet:

```yaml
name: "Preview publish: @exile-watch / doryani"

on:
  pull_request_target:
    types:
      - labeled

jobs:
  preview-publish-package:
    runs-on: ubuntu-latest
    if: contains(github.event.pull_request.labels.*.name, 'preview-publish')
    steps:
      - name: Checkout source code
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.GH_TOKEN }}
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.ref }}

      - name: Preview publish package
        uses: exile-watch/doryani/preview-publish-package@main
        with:
          GH_ACTOR: ${{ github.actor }}
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
          prRef: ${{ github.event.pull_request.head.ref }}
```

## Sub-actions

<table><thead><tr><th width="138" align="center">Action code</th><th width="234">Name</th><th></th></tr></thead><tbody><tr><td align="center"><a href="https://github.com/exile-watch/doryani/blob/main/preview-publish-package/00-create-status-comment/action.yml"><code>00</code></a></td><td>Create status comment</td><td>Creates status comment after <code>preview-publish</code> label is applied to the branch</td></tr><tr><td align="center"><a href="https://github.com/exile-watch/doryani/blob/main/preview-publish-package/01-publish-prerelease/action.yml"><code>01</code></a></td><td>Publish prerelease</td><td>Creates prerelease in <code>x.x.x-preview.x</code> format and publishes to github registry</td></tr><tr><td align="center"><a href="https://github.com/exile-watch/doryani/blob/main/preview-publish-package/02-update-status-comment-on-success/action.yml"><code>02</code></a></td><td>Update status comment on success</td><td>Once the package is published, this action updates the status comment created in <code>00</code></td></tr><tr><td align="center"><a href="https://github.com/exile-watch/doryani/blob/main/preview-publish-package/03-update-status-comment-on-failure/action.yml"><code>03</code></a></td><td>Update status comment on failure</td><td>If <code>00</code> or <code>01</code> action fails, this action updates the status created in <code>00</code></td></tr><tr><td align="center"><a href="https://github.com/exile-watch/doryani/blob/main/preview-publish-package/04-remove-preview-publish-label/action.yml"><code>04</code></a></td><td>Remove preview publish label</td><td>Removes <code>preview-publish</code> label from PR once <code>00</code> is completed</td></tr></tbody></table>
