Skip to content

Commit 4009c45

Browse files
committed
Initial Commit
0 parents  commit 4009c45

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1386
-0
lines changed

.github/workflows/README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Naming rule
2+
```
3+
[EVENT] CONTENT
4+
```
5+
6+
## Workflows
7+
> By default, [Push] includes a manual trigger (dispatch).
8+
9+
- `[Push] Build dev`
10+
- EVENT
11+
- When code is pushed to master
12+
- (triggered by `[Push] Sync CI`)
13+
- When the workflow is manually triggered
14+
- CONTENT
15+
- Build code and push docker image to pyengine
16+
- `[Dispatch] Release`
17+
- EVENT
18+
- When the workflow is manually triggered
19+
- CONTENT
20+
- Build code and push docker image to pyengine and spaceone
21+
- `[Push] Sync CI`
22+
- EVENT
23+
- When code is pushed to master
24+
- (trigger `[Push] Build dev`)
25+
- When the workflow is manually triggered
26+
- CONTENT
27+
- [Push]
28+
- Get workflows from actions and Trigger `[Push] Build dev`
29+
- [Dispatch]
30+
- Just get workflows from actions
31+
32+
- `[PR] Review (TODO)`
33+
34+
## Scenario
35+
- Release:
36+
- Manually trigger `[Dispatch] Release`
37+
- Build Dev (Push):
38+
- Commit code to master branch(`[Push] Sync CI` -> `[Push] Build dev`)
39+
- Build Dev (Dispatch):
40+
- Manually trigger `[Push] Build dev`
41+
- Update workflows:
42+
- Manually trigger `[Push] Sync CI`
+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: "[Dispatch] Release"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: '`vx.y.z` 형태로 버전을 입력해주세요.'
8+
required: true
9+
default: v1.0.0
10+
11+
env:
12+
TAG: ${{ github.event.inputs.tag }}
13+
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL}}
14+
15+
jobs:
16+
condition_check:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: check version format
20+
run: |
21+
if [[ !(${{ env.TAG }} =~ ^v[0-9]\.[0-9]?[0-9]\.[0-9]?[0-9]$) ]];
22+
then
23+
echo "You entered an incorrect version format."
24+
exit 1
25+
fi
26+
- name: debugging
27+
run: |
28+
echo "major=$(echo ${{env.TAG}} | cut -c 2- | cut -d'.' -f1)"
29+
echo "minor=$(echo ${{env.TAG}} | cut -c 2- | cut -d'.' -f2)"
30+
echo "patch=$(echo ${{env.TAG}} | cut -c 2- | cut -d'.' -f3)"
31+
- name: notice when job fails
32+
if: failure()
33+
uses: 8398a7/[email protected]
34+
with:
35+
status: ${{job.status}}
36+
fields: repo,workflow,job
37+
author_name: Github Action Slack
38+
39+
update_master_branch_version_file:
40+
needs: condition_check
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v2
44+
with:
45+
token: ${{ secrets.PAT_TOKEN }}
46+
- name: get versions
47+
run: |
48+
echo "old_version=$(cat src/VERSION)" >> $GITHUB_ENV
49+
echo "old_major=$(cat src/VERSION | cut -c 2- | cut -d'.' -f1)" >> $GITHUB_ENV
50+
echo "old_minor=$(cat src/VERSION | cut -c 2- | cut -d'.' -f2)" >> $GITHUB_ENV
51+
echo "old_patch=$(cat src/VERSION | cut -c 2- | cut -d'.' -f3)" >> $GITHUB_ENV
52+
echo "new_major=$(echo ${{ env.TAG }} | cut -c 2- | cut -d'.' -f1)" >> $GITHUB_ENV
53+
echo "new_minor=$(echo ${{ env.TAG }} | cut -c 2- | cut -d'.' -f2)" >> $GITHUB_ENV
54+
echo "new_patch=$(echo ${{ env.TAG }} | cut -c 2- | cut -d'.' -f3)" >> $GITHUB_ENV
55+
- name: compare versions
56+
run: |
57+
if [ ${{ env.TAG }} == ${{ env.old_version }} ];
58+
then
59+
echo "New version cannot be the same as old version."
60+
exit 1
61+
elif [ ${{ env.old_major }} \> ${{ env.new_major }} ];
62+
then
63+
echo "Old major version cannot be greater than new major version"
64+
exit 1
65+
elif [ ${{ env.old_minor }} \> ${{ env.new_minor }} ];
66+
then
67+
echo "Old minor version cannot be greater than new minor version"
68+
exit 1
69+
elif [ $old_patch ];
70+
then
71+
if [ $old_patch \> $new_patch ];
72+
then
73+
echo "Old patch version cannot be greater than new patch version"
74+
exit 1
75+
else
76+
echo "version=$new_version"
77+
fi
78+
else
79+
echo "version=$new_version"
80+
fi
81+
- name: update version file
82+
run: |
83+
echo ${{ env.TAG }} > src/VERSION
84+
git config user.name github-actions
85+
git config user.email [email protected]
86+
git add .
87+
git commit -m "[CI/CD] release version ${{ env.TAG }}"
88+
- name: push changes
89+
uses: ad-m/github-push-action@master
90+
with:
91+
github_token: ${{ secrets.PAT_TOKEN }}
92+
branch: master
93+
- name: notice when job fails
94+
if: failure()
95+
uses: 8398a7/[email protected]
96+
with:
97+
status: ${{job.status}}
98+
fields: repo,workflow,job
99+
author_name: Github Action Slack
100+
101+
tagging:
102+
needs: update_master_branch_version_file
103+
runs-on: ubuntu-latest
104+
steps:
105+
- uses: actions/checkout@v2
106+
with:
107+
token: ${{ secrets.PAT_TOKEN }}
108+
- name: git tagging
109+
run: |
110+
git tag ${{ env.TAG }}
111+
git push origin "${{ env.TAG }}"
112+
- name: notice when job fails
113+
if: failure()
114+
uses: 8398a7/[email protected]
115+
with:
116+
status: ${{job.status}}
117+
fields: repo,workflow,job
118+
author_name: Github Action Slack
119+
120+
docker:
121+
needs: tagging
122+
if: github.repository_owner == 'spaceone-dev'
123+
runs-on: ubuntu-latest
124+
steps:
125+
- uses: actions/checkout@v2
126+
- name: get version
127+
run: |
128+
echo "VERSION=$(echo ${{ env.TAG }} | cut -c 2-)" >> $GITHUB_ENV
129+
- name: get service name
130+
run: |
131+
echo "SERVICE=$(echo ${{ github.repository }} | cut -d '/' -f2)" >> $GITHUB_ENV
132+
- name: Build and push to pyengine
133+
uses: docker/build-push-action@v1
134+
with:
135+
path: .
136+
repository: pyengine/${{ env.SERVICE }}
137+
username: ${{ secrets.DOCKER_USERNAME }}
138+
password: ${{ secrets.DOCKER_PASSWORD }}
139+
tags: ${{ env.VERSION }}
140+
- name: Build and push to spaceone
141+
uses: docker/build-push-action@v1
142+
with:
143+
path: .
144+
repository: spaceone/${{ env.SERVICE }}
145+
username: ${{ secrets.DOCKER_USERNAME }}
146+
password: ${{ secrets.DOCKER_PASSWORD }}
147+
tags: ${{ env.VERSION }}
148+
- name: Notice when job fails
149+
if: failure()
150+
uses: 8398a7/[email protected]
151+
with:
152+
status: ${{job.status}}
153+
fields: repo,workflow,job
154+
author_name: Github Action Slack
155+
156+
notification:
157+
if: github.repository_owner == 'spaceone-dev'
158+
needs: docker
159+
runs-on: ubuntu-latest
160+
steps:
161+
- name: Slack
162+
if: always()
163+
uses: 8398a7/[email protected]
164+
with:
165+
status: ${{job.status}}
166+
fields: repo,message,commit,author,action,ref,workflow,job
167+
author_name: Github Action Slack

.github/workflows/push_build_dev.yaml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: "[Push] Build dev"
2+
3+
on:
4+
workflow_dispatch:
5+
repository_dispatch:
6+
types: [master_push]
7+
8+
env:
9+
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL}}
10+
11+
jobs:
12+
versioning:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
version: ${{ steps.versioning.outputs.VERSION }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: get current date
19+
run: |
20+
sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
21+
echo "TIME=$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV
22+
- name: set version with current date
23+
id: versioning
24+
run: |
25+
echo "::set-output name=VERSION::$(cat src/VERSION | cut -c 2-).${{ env.TIME }}"
26+
- name: Notice when job fails
27+
if: failure()
28+
uses: 8398a7/[email protected]
29+
with:
30+
status: ${{job.status}}
31+
fields: repo,workflow,job
32+
author_name: Github Action Slack
33+
34+
docker:
35+
if: github.repository_owner == 'spaceone-dev'
36+
needs: versioning
37+
runs-on: ubuntu-latest
38+
env:
39+
VERSION: ${{ needs.versioning.outputs.version }}
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: get service name
43+
run: |
44+
echo "SERVICE=$(echo ${{ github.repository }} | cut -d '/' -f2)" >> $GITHUB_ENV
45+
- name: Upload docker
46+
uses: docker/build-push-action@v1
47+
with:
48+
path: .
49+
repository: pyengine/${{ env.SERVICE }}
50+
username: ${{ secrets.DOCKER_USERNAME }}
51+
password: ${{ secrets.DOCKER_PASSWORD }}
52+
tags: ${{ env.VERSION }}
53+
- name: Notice when job fails
54+
if: failure()
55+
uses: 8398a7/[email protected]
56+
with:
57+
status: ${{job.status}}
58+
fields: repo,workflow,job
59+
author_name: Github Action Slack
60+
61+
notification:
62+
runs-on: ubuntu-latest
63+
needs: docker
64+
steps:
65+
- name: Slack
66+
if: always()
67+
uses: 8398a7/[email protected]
68+
with:
69+
status: ${{job.status}}
70+
fields: repo,message,commit,author,action,ref,workflow,job
71+
author_name: Github Action Slack

.github/workflows/push_sync_ci.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "[Push] Sync CI"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths-ignore:
8+
- '.github/**'
9+
- 'src/VERSION'
10+
workflow_dispatch:
11+
12+
env:
13+
workflow_file_name: deploy.yaml
14+
owner: spaceone-dev
15+
repo: actions
16+
ref: master
17+
18+
jobs:
19+
master_push:
20+
if: github.event_name == 'push'
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: git pull
24+
uses: convictional/[email protected]
25+
with:
26+
owner: ${{ env.owner }}
27+
repo: ${{ env.repo }}
28+
github_token: ${{ secrets.PAT_TOKEN }}
29+
workflow_file_name: ${{ env.workflow_file_name }}
30+
ref: ${{ env.ref }}
31+
wait_interval: 10
32+
inputs: '{"repository" : "${{ github.repository }}"}'
33+
trigger_workflow: true
34+
wait_workflow: true
35+
pull_workflows:
36+
if: github.event_name == 'workflow_dispatch'
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: git pull
40+
uses: convictional/[email protected]
41+
with:
42+
owner: ${{ env.owner }}
43+
repo: ${{ env.repo }}
44+
github_token: ${{ secrets.PAT_TOKEN }}
45+
workflow_file_name: ${{ env.workflow_file_name }}
46+
ref: ${{ env.ref }}
47+
wait_interval: 10
48+
inputs: '{"repository" : "${{ github.repository }}" , "sync_only" : "true"}'
49+
trigger_workflow: true
50+
wait_workflow: true

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.swp
2+
*.bak
3+
disk
4+
build
5+
*.egg-info
6+
*.egg
7+
*.whl
8+
.idea
9+
__pycache__
10+
venv
11+
local-conf.yml
12+
.venv/
13+
.venv.nosync/
14+
.DS_Store

Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM python:3.8
2+
3+
ENV PYTHONUNBUFFERED 1
4+
ENV CLOUDONE_PORT 50051
5+
ENV SERVER_TYPE grpc
6+
ENV PKG_DIR /tmp/pkg
7+
ENV SRC_DIR /tmp/src
8+
9+
COPY pkg/*.txt ${PKG_DIR}/
10+
RUN pip install --upgrade pip && \
11+
pip install --use-deprecated=legacy-resolver --upgrade -r ${PKG_DIR}/pip_requirements.txt && \
12+
pip install --use-deprecated=legacy-resolver --upgrade --pre spaceone-core spaceone-api
13+
14+
COPY src ${SRC_DIR}
15+
16+
WORKDIR ${SRC_DIR}
17+
RUN python3 setup.py install && \
18+
rm -rf /tmp/*
19+
20+
EXPOSE ${CLOUDONE_PORT}
21+
22+
ENTRYPOINT ["spaceone"]
23+
CMD ["grpc", "spaceone.cost_analysis"]

0 commit comments

Comments
 (0)