|
| 1 | +name: Publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: [CI] |
| 6 | + types: [completed] |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + publish: |
| 11 | + if: github.event.workflow_run.conclusion == 'success' |
| 12 | + runs-on: ubuntu-22.04 |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v6 |
| 16 | + with: |
| 17 | + ref: ${{ github.event.workflow_run.head_sha }} |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Detect changed packages |
| 21 | + id: changes |
| 22 | + uses: dorny/paths-filter@v3 |
| 23 | + with: |
| 24 | + base: HEAD^ |
| 25 | + filters: | |
| 26 | + utils: |
| 27 | + - 'packages/utils/**' |
| 28 | + github: |
| 29 | + - 'packages/github/**' |
| 30 | +
|
| 31 | + - name: Setup Node.js |
| 32 | + uses: actions/setup-node@v6 |
| 33 | + with: |
| 34 | + node-version-file: .nvmrc |
| 35 | + registry-url: 'https://registry.npmjs.org' |
| 36 | + scope: '@hawk.so' |
| 37 | + |
| 38 | + - name: Enable Corepack and install dependencies |
| 39 | + run: | |
| 40 | + corepack enable |
| 41 | + corepack prepare yarn@4.5.1 --activate |
| 42 | + yarn install |
| 43 | +
|
| 44 | + - name: Build |
| 45 | + run: yarn build |
| 46 | + |
| 47 | + - name: Publish |
| 48 | + run: | |
| 49 | + if [ "${{ steps.changes.outputs.utils }}" == "true" ]; then |
| 50 | + yarn workspace @hawk.so/utils exec npm publish --access public |
| 51 | + fi |
| 52 | + if [ "${{ steps.changes.outputs.github }}" == "true" ]; then |
| 53 | + yarn workspace @hawk.so/github-sdk exec npm publish --access public |
| 54 | + fi |
| 55 | + env: |
| 56 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 57 | + |
| 58 | + - name: Get published package versions |
| 59 | + if: steps.changes.outputs.utils == 'true' || steps.changes.outputs.github == 'true' |
| 60 | + id: versions |
| 61 | + run: | |
| 62 | + if [ "${{ steps.changes.outputs.utils }}" == "true" ]; then |
| 63 | + echo "utils_version=$(node -p "require('./packages/utils/package.json').version")" >> $GITHUB_OUTPUT |
| 64 | + fi |
| 65 | + if [ "${{ steps.changes.outputs.github }}" == "true" ]; then |
| 66 | + echo "github_version=$(node -p "require('./packages/github/package.json').version")" >> $GITHUB_OUTPUT |
| 67 | + fi |
| 68 | +
|
| 69 | + - name: Notify @hawk.so/utils published |
| 70 | + if: steps.changes.outputs.utils == 'true' |
| 71 | + uses: codex-team/action-codexbot-notify@v1 |
| 72 | + with: |
| 73 | + webhook: ${{ secrets.CODEX_BOT_WEBHOOK_HAWK }} |
| 74 | + message: '📦 [@hawk.so/utils](https://www.npmjs.com/package/@hawk.so/utils) ${{ steps.versions.outputs.utils_version }} was published' |
| 75 | + parse_mode: 'markdown' |
| 76 | + disable_web_page_preview: true |
| 77 | + |
| 78 | + - name: Notify @hawk.so/github-sdk published |
| 79 | + if: steps.changes.outputs.github == 'true' |
| 80 | + uses: codex-team/action-codexbot-notify@v1 |
| 81 | + with: |
| 82 | + webhook: ${{ secrets.CODEX_BOT_WEBHOOK_HAWK }} |
| 83 | + message: '📦 [@hawk.so/github-sdk](https://www.npmjs.com/package/@hawk.so/github-sdk) ${{ steps.versions.outputs.github_version }} was published' |
| 84 | + parse_mode: 'markdown' |
| 85 | + disable_web_page_preview: true |
0 commit comments