-
Notifications
You must be signed in to change notification settings - Fork 20
94 lines (80 loc) · 2.99 KB
/
test_build_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Test, Build & Release
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test_build_release:
runs-on: ubuntu-latest
env:
COMMITTER: ${{github.event.head_commit.committer.name}}
COMMIT_URL: ${{github.event.head_commit.url}}
steps:
- name: Checkout
uses: actions/checkout@v4.1.6
with:
fetch-depth: 0
- name: Set environment variables
run: |
echo "BRANCH_NAME=$(git branch --show-current)" >> $GITHUB_ENV
echo "TAG=$(git tag --points-at ${{github.sha}})" >> $GITHUB_ENV
echo "COMMIT_MESSAGE=$(git log --format=%B -n 1 ${{github.event.after}} | head -n 1)" >> $GITHUB_ENV
- name: Set TITLE
env:
PR_TITLE: ${{github.event.pull_request.title || env.COMMIT_MESSAGE}}
run: echo "TITLE=$PR_TITLE" >> $GITHUB_ENV
- name: Print environment variables
env:
GITHUB_CONTEXT: ${{toJson(github)}}
run: |
echo -e "BRANCH_NAME = ${BRANCH_NAME}"
echo -e "TAG = ${TAG}"
echo -e "TITLE = ${TITLE}"
echo -e "COMMIT_MESSAGE = ${COMMIT_MESSAGE}"
echo -e "COMMIT_URL = ${COMMIT_URL}"
echo -e "COMMITTER = ${COMMITTER}"
echo -e "HOME = ${HOME}"
echo -e "GITHUB_CONTEXT = ${GITHUB_CONTEXT}"
- name: Skip CI
if: |
contains(env.TITLE || env.COMMIT_MESSAGE, '[skip ci]') ||
contains(env.TITLE || env.COMMIT_MESSAGE, '[ci skip]')
uses: andymckay/cancel-action@0.4
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{github.token}}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: 'yarn'
- name: Authenticate git clone
env:
GH_TOKEN: ${{secrets.OTTO_THE_BOT_GH_TOKEN}}
run: echo -e "machine github.com\n login ${GH_TOKEN}" > ~/.netrc
- name: Install JS dependencies
run: yarn --immutable
- name: Test
run: yarn test
- name: Release
if: |
env.BRANCH_NAME == 'main' &&
!startsWith(env.TITLE, 'chore') &&
!startsWith(env.TITLE, 'test')
env:
NPM_TOKEN: ${{secrets.WEBTEAM_NPM_TOKEN}}
run: |
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> "${HOME}/.npmrc"
git config --global user.email webapp+otto@wire.com
git config --global user.name "Otto the Bot"
yarn release
- name: Notify CI error
if: failure() && github.event_name != 'pull_request'
uses: wireapp/github-action-wire-messenger@v2.0.0
with:
email: ${{secrets.WIRE_EMAIL}}
password: ${{secrets.WIRE_PASSWORD}}
conversation: 'b2cc7120-4154-4be4-b0c0-45a8c361c4d1'
text: '🌵 ${{env.COMMITTER}} broke the "${{env.BRANCH_NAME}}" branch on "${{github.repository}}" with [${{env.TITLE}}](${{env.COMMIT_URL}})'