-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (50 loc) · 1.81 KB
/
build.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
name: Build and Deploy
on:
release:
types: [ published ]
env:
SONAR_DIRECTORY: /github/workspace
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2.4.0
- name: Bump version 🔧
if: ${{ !github.base_ref }}
run: |
# Strip git ref prefix from version
VERSION=$(echo "$GITHUB_REF" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "$GITHUB_REF" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo "VERSION: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
npm --no-git-tag-version version "$VERSION"
- name: Create SonarCloud scanner default working directory 🔧
run: |
sudo mkdir --parents "$SONAR_DIRECTORY"
sudo mount --bind "$GITHUB_WORKSPACE" "$SONAR_DIRECTORY"
- name: Install and Build 🔧
run: |
npm install
npm run build
env:
CI: false
REACT_APP_GRAPHQL_URL: ${{secrets.REACT_APP_GRAPHQL_URL}}
REACT_APP_UA_GOOGLE_PROPERTY: ${{secrets.REACT_APP_UA_GOOGLE_PROPERTY}}
GENERATE_SOURCEMAP: false
- name: Test 🔎
run: npm run test
working-directory: ${{ env.SONAR_DIRECTORY }} # Align on SonarCloud scanner default working directory
- name: SonarCloud scan 🔎
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
uses: SonarSource/sonarcloud-github-action@v1.8
with:
args: -Dsonar.projectVersion=${{ env.VERSION }}
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: master
folder: build