Skip to content

Commit ea3db4e

Browse files
author
sharma.yash
committed
Github CI/CD actions added..intial push
1 parent ef7cc05 commit ea3db4e

File tree

5 files changed

+148
-77
lines changed

5 files changed

+148
-77
lines changed

Diff for: .github /workflows/ci.yml

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: CI
2+
on: [push]
3+
4+
jobs:
5+
build-and-test:
6+
runs-on: ubuntu-latest
7+
permissions:
8+
contents: "read"
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v3
12+
13+
- name: Setup with node and yarn
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: "16"
17+
cache-dependency-path: "web/yarn.lock"
18+
19+
- name: Set yarn version
20+
run: make web/set-yarn-version
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v3
24+
with:
25+
go-version: "^1.18"
26+
27+
- name: Build web
28+
run: make web/build
29+
30+
- name: Run web test
31+
run: make web/test
32+
33+
- name: Build
34+
run: make bin/linux
35+
36+
- name: Run Go test
37+
run: make go/test
38+
39+
cancel:
40+
runs-on: [ self-hosted ]
41+
name: Cancel Previous Runs
42+
if: always()
43+
steps:
44+
- uses: styfle/cancel-workflow-action@d57d93c3a8110b00c3a2c0b64b8516013c9fd4c9
45+
if: github.ref != 'refs/heads/master'
46+
name: cancel old workflows
47+
id: cancel
48+
with:
49+
access_token: ${{ secrets.GITHUB_TOKEN }}
50+
- if: github.ref == 'refs/heads/master'
51+
name: Don't cancel old workflows
52+
id: dont_cancel
53+
run: |
54+
echo "Don't cancel old workflow"
55+
56+
build-docker-server:
57+
runs-on: [self-hosted]
58+
name: Build docker image for the server
59+
continue-on-error: false
60+
steps:
61+
- name: Login to Harbor
62+
uses: docker/login-action@v1
63+
with:
64+
registry: c.rzp.io
65+
username: ${{ secrets.HARBOR_DOCKER_USERNAME }}
66+
password: ${{ secrets.HARBOR_DOCKER_PASSWORD }}
67+
68+
- name: Set up Docker Buildx
69+
id: buildx
70+
uses: docker/setup-buildx-action@v1
71+
72+
- name: Set date and commit ID as tag
73+
run: |
74+
echo "CURRENT_DATE=$(date +"%Y%m%d")" >> $GITHUB_ENV
75+
echo "COMMIT_ID=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
76+
77+
- name: Build and push
78+
uses: docker/build-push-action@v2
79+
with:
80+
tags: c.rzp.io/razorpay/docvault:server-${{ env.CURRENT_DATE }}-${{ github.sha }}
81+
push: true
82+
file: Dockerfile.server
83+
target: prod-api
84+
secrets: |
85+
GIT_TOKEN=${{ secrets.GIT_TOKEN }}
86+
build-args: |
87+
GIT_COMMIT_HASH=${{ github.sha }}
88+
GIT_USERNAME=rzp
89+
90+
build-docker-indexer:
91+
runs-on: [self-hosted]
92+
name: Build docker image for the indexer
93+
continue-on-error: false
94+
steps:
95+
- name: Login to Harbor
96+
uses: docker/login-action@v1
97+
with:
98+
registry: c.rzp.io
99+
username: ${{ secrets.HARBOR_DOCKER_USERNAME }}
100+
password: ${{ secrets.HARBOR_DOCKER_PASSWORD }}
101+
102+
- name: Set up Docker Buildx
103+
id: buildx
104+
uses: docker/setup-buildx-action@v1
105+
106+
- name: Set date and commit ID as tag
107+
run: |
108+
echo "CURRENT_DATE=$(date +"%Y%m%d")" >> $GITHUB_ENV
109+
echo "COMMIT_ID=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
110+
111+
- name: Build and push
112+
uses: docker/build-push-action@v2
113+
with:
114+
tags: c.rzp.io/razorpay/docvault:indexer-${{ env.CURRENT_DATE }}-${{ github.sha }}
115+
push: true
116+
file: Dockerfile.indexer
117+
target: prod-api
118+
secrets: |
119+
GIT_TOKEN=${{ secrets.GIT_TOKEN }}
120+
build-args: |
121+
GIT_COMMIT_HASH=${{ github.sha }}
122+
GIT_USERNAME=rzp
123+
124+
125+
workflow_status:
126+
runs-on: [self-hosted]
127+
continue-on-error: false
128+
name: Update Status Check
129+
needs: [ build-docker-indexer, build-docker-server ]
130+
if: always()
131+
steps:
132+
- name: Failed
133+
id: failed
134+
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
135+
run: |
136+
echo 'Failing the workflow for github status check.'
137+
curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
138+
-d '{ "state" : "failure" , "context" : "github/combined-status-check" , "description" : "github/combined-status-check", "target_url" : "https://github.com/${{ github.repository }}" }' \
139+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}
140+
exit 1
141+
- name: Success
142+
if: steps.failed.conclusion == 'skipped'
143+
run: |
144+
echo 'Status check has passed!'
145+
curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
146+
-d '{ "state" : "success" , "context" : "github/combined-status-check" , "description" : "github/combined-status-check", "target_url" : "https://github.com/${{ github.repository }}" }' \
147+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}
148+
exit 0

Diff for: .github/CODEOWNERS

-1
This file was deleted.

Diff for: .github/pull_request_template.md

-14
This file was deleted.

Diff for: .github/workflows/ci.yml

-42
This file was deleted.

Diff for: .github/workflows/trigger-deploy.yml

-20
This file was deleted.

0 commit comments

Comments
 (0)