-
Notifications
You must be signed in to change notification settings - Fork 3
106 lines (93 loc) · 3.17 KB
/
app_CICD.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
95
96
97
98
99
100
101
102
103
104
105
106
name: APP CI/CD
on:
push:
branches:
- master
paths:
- 'trails-viz-app/**'
pull_request:
branches:
- master
paths:
- 'trails-viz-app/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '12'
- name: Install dependencies
run: |
cd trails-viz-app
npm install
- name: Run lint and build project
run: |
set -e
cd trails-viz-app
npm run lint
npm run build
- name: Upload build artifact # save the dist folder as an artifact
if: github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: trails-viz-app-dist
path: trails-viz-app/dist
deploy:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' # only deploy on push event
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download build artifact # download the dist folder from build
uses: actions/download-artifact@v4
with:
name: trails-viz-app-dist
path: trails-viz-app/dist
- name: Setup git user identity
run: |
git config --global user.name "outdoorrd-bot"
git config --global user.email "[email protected]"
- name: Update app version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
commit_message=$(git log -1 --pretty=%B) # Get commit message
echo "Updating version..."
if [[ "$commit_message" == *"release=major"* ]]; then
version_bump="major"
elif [[ "$commit_message" == *"release=minor"* ]]; then
version_bump="minor"
elif [[ "$commit_message" == *"release=patch"* ]]; then
version_bump="patch"
else
version_bump="patch"
fi
# update the version in package.json as it's the easiest thing to do using npm
git checkout master
# Pull latest changes before version bump
git pull origin master
cd trails-viz-app
new_version=$(npm version $version_bump) # this returns the new version number with 'v' as prefix
new_version_number=${new_version#v} # Remove the 'v' prefix
cd ..
echo "local version bump successful $new_version"
git add trails-viz-app/package.json
git add trails-viz-app/package-lock.json
git commit -m "Auto update app version to $new_version_number"
echo "commited after version update"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git push origin master
git tag "app-$new_version"
git push origin --tags
echo "pushed new versioning update to master"
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: trails-viz-app/dist