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: GitHub Action Slack Notify CI | |
on: | |
- push | |
- pull_request | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Use Node.js v20.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 20 | |
- name: Notify slack | |
# Don't attempt to send Slack notifications on fork PRs which don't have access to secrets | |
if: env.SLACK_BOT_TOKEN | |
id: slack | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
uses: ./ | |
with: | |
channel_id: CB9QT2NNR | |
status: STARTED | |
color: warning | |
- name: Get yarn cache | |
id: yarn-cache | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- uses: actions/cache@v1 | |
with: | |
path: ${{ steps.yarn-cache.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: yarn install and test | |
run: | | |
yarn | |
yarn test | |
env: | |
CI: true | |
- name: yarn build | |
run: yarn build | |
- name: release | |
if: ${{ endsWith(github.ref, '/main') }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: npx semantic-release | |
- name: update v1 tag | |
if: ${{ endsWith(github.ref, '/main') }} | |
run: 'git push -f https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/v1' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Notify slack success | |
if: env.SLACK_BOT_TOKEN | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
uses: ./ | |
with: | |
message_id: ${{ steps.slack.outputs.message_id }} | |
channel_id: CB9QT2NNR | |
status: SUCCESS | |
color: good |