-
-
Notifications
You must be signed in to change notification settings - Fork 182
121 lines (112 loc) · 4.57 KB
/
dev-build-release.yaml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Build the project and tag,version it and release to dev env
on:
push:
branches:
- '*'
env:
project-directory: ./
jobs:
release:
name: Build Frontend Project
runs-on: ubuntu-latest
if: |
!contains(github.event.head_commit.message, 'skip-ci')
steps:
# checkout the branch to be merged
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: git configure
run: |
git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf ssh://[email protected]
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Read .releaserc
run: echo "RELEASE_NEEDED=$(echo `node -e 'console.log(require("./.releaserc.json").branches.map(e => e.name || e).reduce((a,c) => a || c === process.env.GITHUB_REF_NAME, false))'`)" >> $GITHUB_OUTPUT
id: release_needed
- name: Print rn
run: echo ${{ steps.release_needed.outputs.RELEASE_NEEDED }}
- name: Quit if version is not changed
if: steps.release_needed.outputs.RELEASE_NEEDED == 'false'
run: echo "The branch is not configured to release. Quitting." && exit 0
- name: npm clean install
run: npm i
working-directory: ${{ env.project-directory }}
- run: npm i -g semantic-release @semantic-release/{git,exec,changelog}
- run: semantic-release --debug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
# next.js build
- name: build next
run: npm run build
working-directory: ${{ env.project-directory }}
env:
NODE_ENV: production
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build snapshot and push on merge
id: docker_build_release
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: greenstand/${{ github.event.repository.name }}:${{ steps.package-version.outputs.current-version }}
- id: export_bumped_version
run: |
export BUMPED_VERSION="${{ steps.package-version.outputs.current-version }}"
echo "bumped_version=${BUMPED_VERSION}" >> $GITHUB_OUTPUT
outputs:
bumped_version: ${{ steps.export_bumped_version.outputs.bumped_version }}
deploy:
name: Deploy to dev
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: git configure
run: |
git config --global url."https://${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf ssh://[email protected]
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: '18.x'
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
# get bumped version from release job output
- name: get bumped version
id: get_bumped_version
run: |
echo "bumped_version=${{ needs.release.outputs.bumped_version }}" >> $GITHUB_OUTPUT
- name: Install kustomize
run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
#- name: Load channel
# run: echo CHANNEL=$(echo `node -e ' process.env.GITHUB_REF_NAME === "master" ? console.log("master") :console.log(require("./.releaserc.json").branches.reduce((a,c) => a || c.name === process.env.GITHUB_REF_NAME && "-" + c.channel, false))'`) >> $GITHUB_OUTPUT
# id: channel
#- name: Print channel
# run: echo ${{ steps.channel.outputs.CHANNEL }}
- name: Run kustomize
run: (cd deployment/base && ../../kustomize edit set image greenstand/${{ github.event.repository.name }}:${{needs.release.outputs.bumped_version}} )
- name: Install doctl for kubernetes
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DEV_DIGITALOCEAN_TOKEN }}
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ secrets.DEV_CLUSTER_NAME }}
- name: Update kubernetes resources
run: kustomize build deployment/overlays/development | kubectl apply -n ${{ secrets.K8S_NAMESPACE }} --wait -f -