Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI-CD] GitHub Action #270

Merged
merged 38 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
224aa24
create GitHub action for platform deployment
danielogen Jun 7, 2021
cae78ed
update action name
danielogen Jun 9, 2021
8a605ea
create deployment actions
danielogen Jun 9, 2021
9c76f3b
update login to k8s
danielogen Jun 9, 2021
7544185
update log messages
danielogen Jun 9, 2021
fe2e356
update dockerignore file to test pipeline
danielogen Jun 9, 2021
410243c
update gcr secret
danielogen Jun 9, 2021
735f230
test actions
danielogen Jun 9, 2021
e085f48
more testing
danielogen Jun 9, 2021
0a5b45a
updated
danielogen Jun 9, 2021
7b02a4e
more update
danielogen Jun 9, 2021
4c9c496
update docker ignore
danielogen Jun 9, 2021
913ddc8
update paths
danielogen Jun 9, 2021
63b971e
update docker file
danielogen Jun 9, 2021
8ed1201
add --file flage
danielogen Jun 9, 2021
630f559
update dockerignore file
danielogen Jun 9, 2021
d5a959d
correct sp
danielogen Jun 9, 2021
d56034f
update dockerignore
danielogen Jun 9, 2021
8b19d77
run only when PR is merged
danielogen Jun 9, 2021
96c7459
add production action
danielogen Jun 9, 2021
2a06219
undo changes in docker file
danielogen Jun 9, 2021
fca5a03
set branch to dev
danielogen Jun 10, 2021
6bd3e06
add config to build react app
danielogen Jun 10, 2021
06de5c7
test frontend staging
danielogen Jun 11, 2021
86fad55
test platform deployment
danielogen Jun 11, 2021
90890a0
test platform deployment
danielogen Jun 11, 2021
230f293
update path to imports
danielogen Jun 11, 2021
78fabb3
update import path
danielogen Jun 11, 2021
db9521b
update staging pipeline
danielogen Jun 11, 2021
beacb45
update production pipeline
danielogen Jun 11, 2021
d0bb922
set NODE_PATH
danielogen Jun 16, 2021
c381541
set NODE_PATH
danielogen Jun 16, 2021
e1f2a40
set NODE_PATH
danielogen Jun 16, 2021
a096612
set CI env to false
danielogen Jun 16, 2021
b94184f
update pipeline
danielogen Jun 16, 2021
a731a58
undo changes to import
danielogen Jun 16, 2021
90dc8a5
update pipeline
danielogen Jun 16, 2021
d5f2d14
test pipeline
danielogen Jun 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/deploy-platform-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: deploy-platform-production

on:
#push:
pull_request:
branches: master
types: [closed]
jobs:
check:
if: github.event.pull_request.merged == 'true'
#if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
name: check for changes in platform
outputs:
run_job: ${{ steps.check_files.outputs.run_job }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: check modified files
id: check_files
run: |
echo "=============== list modified files ==============="
git diff --name-only HEAD^ HEAD

echo "========== check paths of modified files =========="
git diff --name-only HEAD^ HEAD > files.txt

echo "::set-output name=run_job::false"

while IFS= read -r file
do
echo $file
if [[ $file == netmanager/* ]]; then
echo "::set-output name=run_job::true"
fi
done < files.txt

build:
name: build-push-deploy
needs: check
if: needs.check.outputs.run_job == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Login to GCR
uses: docker/login-action@v1
with:
registry: ${{ secrets.REGISTRY_URL }}
username: _json_key
password: ${{ secrets.GCR_CONFIG }}

- name: Login to K8S
uses: azure/k8s-set-context@v1
with:
method: kubeconfig
kubeconfig: ${{ secrets.K8S_CONFIG }}

- name: NPM Build
run: |
cd netmanager/
export NODE_PATH=src/
npm install
npm audit fix
CI=false npm run build

- name: Build and Push Docker Image
run: |
cd netmanager/
docker build --tag ${{ secrets.REGISTRY_URL }}/${{ secrets.PROJECT_ID }}/airqo-platform-frontend:latest .
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.PROJECT_ID }}/airqo-platform-frontend:latest
- name: Deploy to K8S
run: |
cd k8s/
kubectl apply -f airqo-platform-frontend.yaml
kubectl rollout restart deployment/airqo-platform-frontend -n production


83 changes: 83 additions & 0 deletions .github/workflows/deploy-platform-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: deploy-platform-staging

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering, aren't we able to reuse the same configuration file for multiple environments? @danielogen
But I guess it is not yet possible as seen here: actions/starter-workflows#245

on:
push:
#pull_request:
branches: ft-deploy-platform
#types: [closed]
jobs:
check:
#if: github.event.pull_request.merged == 'true'
#if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
name: check for changes in platform
outputs:
run_job: ${{ steps.check_files.outputs.run_job }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: check modified files
id: check_files
run: |
echo "=============== list modified files ==============="
git diff --name-only HEAD^ HEAD

echo "========== check paths of modified files =========="
git diff --name-only HEAD^ HEAD > files.txt

echo "::set-output name=run_job::false"

while IFS= read -r file
do
echo $file
if [[ $file == netmanager/* ]]; then
echo "::set-output name=run_job::true"
break
fi
done < files.txt

build:
name: build-push-deploy-netmanager
needs: check
if: needs.check.outputs.run_job == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Login to GCR
uses: docker/login-action@v1
with:
registry: ${{ secrets.REGISTRY_URL }}
username: _json_key
password: ${{ secrets.GCR_CONFIG }}

- name: Login to K8S
uses: azure/k8s-set-context@v1
with:
method: kubeconfig
kubeconfig: ${{ secrets.K8S_CONFIG }}

- name: NPM Build
run: |
cd netmanager/
export NODE_PATH=src/
npm install
npm audit fix
CI=false npm run build

- name: Build and Push Docker Image
run: |
cd netmanager/
docker build --tag ${{ secrets.REGISTRY_URL }}/${{ secrets.PROJECT_ID }}/airqo-stage-platform-frontend:latest .
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.PROJECT_ID }}/airqo-stage-platform-frontend:latest
- name: Deploy to K8S
run: |
cd k8s/
kubectl apply -f stage-airqo-platform-frontend.yaml
kubectl rollout restart deployment/airqo-stage-platform-frontend -n staging


5 changes: 4 additions & 1 deletion netmanager/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ npm-debug.log
.dockerignore
**/.git
**/.DS_Store
**/node_modules
**/node_modules
.gcloudignore
README.md
app.yaml