-
Notifications
You must be signed in to change notification settings - Fork 99
74 lines (69 loc) · 3.33 KB
/
CI-CD.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
name: CI/CD
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
# Mongo is needed for running tests
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 4.2
- uses: actions/checkout@v1
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 10.x
- name: Fix up git URLs
run: echo -e '[url "https://github.com/"]\n insteadOf = "git://github.com/"' >> ~/.gitconfig
- name: install dependencies
run: npm ci
- name: run linter
run: npm run eslint
- name: test
run: npm run test
publish:
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
needs: test
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Build image and push to GitHub Packages
uses: docker/build-push-action@v1
with:
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ghcr.io
repository: giveth/feathers-giveth
add_git_labels: true
# Add branch name to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref}
tag_with_ref: true
# Add commit hash to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha}
tag_with_sha: true
deploy:
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
needs: publish
runs-on: ubuntu-latest
steps:
- name: develop deploy
if: github.ref == 'refs/heads/develop'
uses: garygrossgarten/[email protected]
with:
# command: cd feathers-giveth-develop && git checkout develop && git pull origin develop && [[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh && nvm use 10 && npm ci && NODE_ENV=develop ./node_modules/.bin/migrate-mongo up && npm run serve
# pull images, restart docker, then remove unused docker images
command: cd feathers-giveth-develop && git checkout develop && git pull origin develop && git pull origin develop && docker-compose -f docker-compose-develop.yml pull && docker-compose -f docker-compose-develop.yml down && docker-compose -f docker-compose-develop.yml up -d && docker image prune -a --force
host: ${{ secrets.DEVELOP_HOST }}
username: ${{ secrets.DEVELOP_USERNAME }}
# passphrase: ${{ secrets.PASSPHRASE }}
privateKey: ${{ secrets.DEVELOP_PRIVATE_KEY}}
- name: production deploy
if: github.ref == 'refs/heads/master'
uses: garygrossgarten/[email protected]
with:
# pull images, restart docker, then remove unused docker images
command: cd feathers-giveth-trace && git checkout master && git pull origin master && docker-compose -f docker-compose-production.yml pull && docker-compose -f docker-compose-production.yml down && docker-compose -f docker-compose-production.yml up -d && docker image prune -a --force
host: ${{ secrets.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USERNAME }}
# passphrase: ${{ secrets.PASSPHRASE }}
privateKey: ${{ secrets.PRODUCTION_PRIVATE_KEY}}