Skip to content

Commit 31f8cd3

Browse files
[CI] Deploy CI
1 parent d500683 commit 31f8cd3

1 file changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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+
owner_check:
17+
if: github.repository_owner == 'cloudforet-io'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- run: echo ${{ github.repository_owner }}
21+
condition_check:
22+
if: github.repository_owner == 'cloudforet-io'
23+
runs-on: ubuntu-latest
24+
needs: owner_check
25+
steps:
26+
- name: check version format
27+
run: |
28+
if [[ !(${{ env.TAG }} =~ ^v[0-9]\.[0-9]?[0-9]\.[0-9]?[0-9]$) ]];
29+
then
30+
echo "You entered an incorrect version format."
31+
exit 1
32+
fi
33+
- name: debugging
34+
run: |
35+
echo "major=$(echo ${{env.TAG}} | cut -c 2- | cut -d'.' -f1)"
36+
echo "minor=$(echo ${{env.TAG}} | cut -c 2- | cut -d'.' -f2)"
37+
echo "patch=$(echo ${{env.TAG}} | cut -c 2- | cut -d'.' -f3)"
38+
- name: notice when job fails
39+
if: failure()
40+
uses: 8398a7/action-slack@v3.2.0
41+
with:
42+
status: ${{job.status}}
43+
fields: repo,workflow,job
44+
author_name: Github Action Slack
45+
46+
update_master_branch_version_file:
47+
needs: condition_check
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v2
51+
with:
52+
token: ${{ secrets.PAT_TOKEN }}
53+
- name: update version file # That is used where the master_push actions
54+
run: |
55+
echo ${{ env.TAG }} > src/VERSION
56+
git config user.name github-actions
57+
git config user.email github-actions@github.com
58+
git add .
59+
git commit -m "[CI/CD] release version ${{ env.TAG }}"
60+
- name: push changes
61+
uses: ad-m/github-push-action@master
62+
with:
63+
github_token: ${{ secrets.PAT_TOKEN }}
64+
branch: master
65+
- name: notice when job fails
66+
if: failure()
67+
uses: 8398a7/action-slack@v3.2.0
68+
with:
69+
status: ${{job.status}}
70+
fields: repo,workflow,job
71+
author_name: Github Action Slack
72+
73+
tagging:
74+
needs: update_master_branch_version_file
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@v2
78+
with:
79+
token: ${{ secrets.PAT_TOKEN }}
80+
- name: git tagging
81+
run: |
82+
git tag ${{ env.TAG }}
83+
git push origin "${{ env.TAG }}"
84+
- name: notice when job fails
85+
if: failure()
86+
uses: 8398a7/action-slack@v3.2.0
87+
with:
88+
status: ${{job.status}}
89+
fields: repo,workflow,job
90+
author_name: Github Action Slack
91+
92+
docker:
93+
needs: tagging
94+
runs-on: ubuntu-latest
95+
steps:
96+
- uses: actions/checkout@v2
97+
- name: get version
98+
run: |
99+
echo "VERSION=$(echo ${{ env.TAG }} | cut -c 2-)" >> $GITHUB_ENV
100+
- name: get service name
101+
run: |
102+
echo "SERVICE=$(echo ${{ github.repository }} | cut -d '/' -f2)" >> $GITHUB_ENV
103+
- name: Build and push to pyengine
104+
uses: docker/build-push-action@v1
105+
with:
106+
path: .
107+
repository: pyengine/${{ env.SERVICE }}
108+
username: ${{ secrets.DOCKER_USERNAME }}
109+
password: ${{ secrets.DOCKER_PASSWORD }}
110+
tags: ${{ env.VERSION }}
111+
- name: Build and push to spaceone
112+
uses: docker/build-push-action@v1
113+
with:
114+
path: .
115+
repository: spaceone/${{ env.SERVICE }}
116+
username: ${{ secrets.DOCKER_USERNAME }}
117+
password: ${{ secrets.DOCKER_PASSWORD }}
118+
tags: ${{ env.VERSION }}
119+
- name: Notice when job fails
120+
if: failure()
121+
uses: 8398a7/action-slack@v3.2.0
122+
with:
123+
status: ${{job.status}}
124+
fields: repo,workflow,job
125+
author_name: Github Action Slack
126+
127+
notification:
128+
needs: docker
129+
runs-on: ubuntu-latest
130+
steps:
131+
- name: Slack
132+
if: always()
133+
uses: 8398a7/action-slack@v3.2.0
134+
with:
135+
status: ${{job.status}}
136+
fields: repo,message,commit,author,action,ref,workflow,job
137+
author_name: Github Action Slack

0 commit comments

Comments
 (0)