Merge pull request #59 from accruteam/develop #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
id-token: write | |
steps: | |
- name: Checkout to Branch | |
uses: actions/checkout@v3 | |
- name: Setup Node.js 20 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Lint | |
run: yarn lint | |
- name: Create Release Pull Request or Publish to npm | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
publish: yarn release | |
env: | |
HUSKY: 0 | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Send a Slack notification if a publish happens | |
if: steps.changesets.outputs.published == 'true' | |
id: slack | |
uses: slackapi/slack-github-action@v1.26.0 | |
with: | |
channel-id: ${{ vars.SLACK_CHANNEL_ID }} | |
payload: | | |
{ | |
"text": "A new version of ${GITHUB_REPOSITORY} was published! :tada:", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": ":package: *${{ fromJSON(steps.changesets.outputs.publishedPackages)[0].name }} v${{ fromJSON(steps.changesets.outputs.publishedPackages)[0].version }} published* :rocket:\n Update frontend using `yarn add ${{ fromJSON(steps.changesets.outputs.publishedPackages)[0].name }}@${{ fromJSON(steps.changesets.outputs.publishedPackages)[0].version }}`" | |
} | |
}, | |
{ | |
"type": "actions", | |
"elements": [ | |
{ | |
"type": "button", | |
"text": { | |
"type": "plain_text", | |
"text": ":mag_right: See action run" | |
}, | |
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
}, | |
{ | |
"type": "button", | |
"text": { | |
"type": "plain_text", | |
"text": ":package: Open NPM package" | |
}, | |
"url": "https://www.npmjs.com/package/${{ fromJSON(steps.changesets.outputs.publishedPackages)[0].name }}/v/${{ fromJSON(steps.changesets.outputs.publishedPackages)[0].version }}" | |
} | |
] | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |