Skip to content

Publish Packages

Publish Packages #503

Workflow file for this run

name: Publish Packages
on:
workflow_dispatch:
inputs:
publishFlag:
description: 'which version to publish eg: alpha, beta, latest, experimental'
required: true
default: 'alpha'
repository_dispatch:
types: [publish-command]
jobs:
publish_packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- name: Check for main branch if latest
if: (github.event.inputs.publishFlag == 'latest' || github.event.client_payload.slash_command.args.unnamed.arg1 == 'latest') && github.ref_name != 'main'
run: exit 1
- name: Notify slack starting
if: github.event.inputs.publishFlag == 'latest' && success()
id: slack # IMPORTANT: reference this step ID value in future Slack steps
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_DEPLOY_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel_id: ${{ secrets.SLACK_DEPLOY_PROD_CHANNEL_ID }}
status: Start
color: warning
- name: Install packages
run: yarn install
- name: Test
run: yarn test
- name: Configure Git user
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
- name: Notify slack publish
if: github.event.inputs.publishFlag == 'latest' && success()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_DEPLOY_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
message_id: ${{ steps.slack.outputs.message_id }}
channel_id: ${{ secrets.SLACK_DEPLOY_PROD_CHANNEL_ID }}
status: Publishing
color: "#bada55"
# from-package will publish whatever version is present in each package's package.json
# it will not publish if the version is already published in npm
- name: Publish
run: yarn lerna:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLISH_FLAG: ${{ github.event.inputs.publishFlag || github.event.client_payload.slash_command.args.unnamed.arg1 || 'alpha' }}
- name: Delay for 1 minute
run: sleep 60
- name: Notify slack success
if: github.event.inputs.publishFlag == 'latest' && success()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_DEPLOY_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
message_id: ${{ steps.slack.outputs.message_id }}
channel_id: ${{ secrets.SLACK_DEPLOY_PROD_CHANNEL_ID }}
status: Success
color: good
- name: Notify slack fail
if: github.event.inputs.publishFlag == 'latest' && failure()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_DEPLOY_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
message_id: ${{ steps.slack.outputs.message_id }}
channel_id: ${{ secrets.SLACK_DEPLOY_PROD_CHANNEL_ID }}
status: Failed
color: danger
notify_100ms_links:
runs-on: ubuntu-latest
needs: publish_packages
steps:
- name: Repository Dispatch
if: success()
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT }}
repository: 100mslive/100ms-links
event-type: alpha-publish
client-payload: '{"bump": "${{ github.event.inputs.publishFlag }}"}'