Skip to content

Commit bc97f39

Browse files
fix: workflow
1 parent 464d515 commit bc97f39

18 files changed

+719
-55
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# .github/workflows/check-pull-request.yml
2+
name: Check Pull Request
3+
4+
on:
5+
pull_request_target:
6+
7+
jobs:
8+
check-pull-request:
9+
name: Check Pull Request
10+
runs-on: ubuntu-latest
11+
permissions:
12+
pull-requests: write
13+
steps:
14+
- name: Check signed commits
15+
id: review
16+
uses: cloudforet-io/check-pr-action@v1
17+
with:
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- name: Notify Result
21+
if: ${{ steps.review.outputs.signedoff == 'false' }}
22+
run: |
23+
echo "The review result is ${{ steps.review.outputs.signedoff }}"
24+
exit 1

.github/workflows/check_pull_request.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/dispatch_build_dev.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: "[Dispatch] Create Branch"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch_name:
7+
description: enter branch (release-x.y)
8+
required: true
9+
default: 'release-1.0'
10+
11+
jobs:
12+
create_branch:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: create branch
16+
uses: peterjgrainger/[email protected]
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
19+
with:
20+
branch: '${{ github.event.inputs.branch_name }}'
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: "[Dispatch] Daily build"
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
BRANCH_NAME: master
8+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
9+
10+
jobs:
11+
docker:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
TIME: ${{ steps.get_date.outputs.TIME }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
ref: ${{ env.BRANCH_NAME }}
20+
token: ${{ secrets.PAT_TOKEN }}
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v2
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v2
27+
28+
- name: Login to Docker Hub
29+
uses: docker/login-action@v2
30+
with:
31+
username: ${{ secrets.CLOUDFORET_DEV_DOCKER_USERNAME }}
32+
password: ${{ secrets.CLOUDFORET_DEV_DOCKER_PASSWORD }}
33+
34+
- name: Get Date
35+
id: get_date
36+
run: |
37+
sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
38+
CURRENT_TIME=$(date +'%Y%m%d.%H%M%S')
39+
40+
echo "TIME=$CURRENT_TIME" >> $GITHUB_ENV
41+
echo "TIME=$CURRENT_TIME" >> $GITHUB_OUTPUT
42+
43+
- name: Build and push to dockerhub
44+
uses: docker/build-push-action@v4
45+
with:
46+
context: .
47+
push: true
48+
tags: |
49+
cloudforetdev/${{ github.event.repository.name }}:latest
50+
cloudforetdev/${{ github.event.repository.name }}:${{ env.TIME }}
51+
build-args: |
52+
PACKAGE_VERSION=${{ env.PACKAGE_VERSION }}
53+
BRANCH_NAME=${{ env.BRANCH_NAME }}
54+
provenance: false
55+
56+
- name: Notice when job fails
57+
if: failure()
58+
uses: 8398a7/[email protected]
59+
with:
60+
status: ${{job.status}}
61+
fields: repo,workflow,job
62+
author_name: Github Action Slack
63+
64+
scan:
65+
needs: docker
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Run Trivy vulnerability scanner
69+
id: trivy-scan
70+
uses: aquasecurity/trivy-action@master
71+
with:
72+
image-ref: cloudforetdev/${{ github.event.repository.name }}:${{ needs.docker.outputs.TIME }}
73+
format: 'sarif'
74+
output: 'trivy-results.sarif'
75+
ignore-unfixed: true
76+
vuln-type: 'os,library'
77+
severity: 'CRITICAL,HIGH'
78+
79+
- name: Upload Trivy scan results to GitHub Security tab
80+
uses: github/codeql-action/upload-sarif@v3
81+
with:
82+
sarif_file: 'trivy-results.sarif'
83+
84+
- name: Count vulnerabilities
85+
id: vulnerabilities
86+
run: |
87+
count=$(jq '.runs[].results[].ruleId' ./trivy-results.sarif | wc -c)
88+
echo "result_count=$count" >> $GITHUB_OUTPUT
89+
echo "$count"
90+
91+
- name: slack
92+
if: ${{ steps.vulnerabilities.outputs.result_count != 0 }}
93+
uses: 8398a7/action-slack@v3
94+
with:
95+
status: custom
96+
fields: workflowRun
97+
custom_payload: |
98+
{
99+
"blocks": [
100+
{
101+
"type": "section",
102+
"text": {
103+
"type": "mrkdwn",
104+
"text": ":warning: Image vulnerability detected"
105+
}
106+
},
107+
{
108+
"type": "section",
109+
"fields": [
110+
{
111+
"type": "mrkdwn",
112+
"text": "*Image:*\ncloudforetdev/${{ github.event.repository.name }}:${{ needs.docker.outputs.TIME }}"
113+
},
114+
{
115+
"type": "mrkdwn",
116+
"text": "*Repo name:*\n${{ github.repository }}"
117+
}
118+
]
119+
},
120+
{
121+
"type": "actions",
122+
"elements": [
123+
{
124+
"type": "button",
125+
"text": {
126+
"type": "plain_text",
127+
"emoji": true,
128+
"text": "View Detail"
129+
},
130+
"style": "danger",
131+
"url": "https://github.com/${{ github.repository }}/security/code-scanning"
132+
}
133+
]
134+
}
135+
]
136+
}
137+
env:
138+
SLACK_WEBHOOK_URL: ${{secrets.VULNERABILITY_SLACK_WEBHOOK_URL}}
139+
140+
notification:
141+
needs: docker
142+
runs-on: ubuntu-latest
143+
steps:
144+
- name: Slack
145+
if: always()
146+
uses: 8398a7/[email protected]
147+
with:
148+
status: ${{job.status}}
149+
fields: repo,message,commit,author,action,ref,workflow,job
150+
author_name: Github Action Slack
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: "[Dispatch] Make Helm Chart"
2+
on:
3+
workflow_dispatch:
4+
repository_dispatch:
5+
types: [make_helm_chart]
6+
7+
env:
8+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GITHUB_HELM_CHART_WEBHOOK_URL }}
9+
10+
jobs:
11+
helm_cloudforet:
12+
if: github.repository_owner == 'cloudforet-io'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Install Helm
18+
uses: azure/setup-helm@v1
19+
with:
20+
version: '3.4.0'
21+
22+
- name: Run Helm packaging
23+
run: |
24+
export cache_dir=/tmp/helm
25+
mkdir -p "$cache_dir"
26+
echo "Installing chart-releaser..."
27+
curl -sSLo cr.tar.gz "https://github.com/helm/chart-releaser/releases/download/v1.2.0/chart-releaser_1.2.0_linux_amd64.tar.gz"
28+
tar -xzf cr.tar.gz -C "$cache_dir"
29+
rm -f cr.tar.gz
30+
echo 'Adding cr directory to PATH...'
31+
export PATH="$cache_dir:$PATH"
32+
rm -rf .deploy
33+
echo 'Print Version ...'
34+
export SERVICE=$(echo ${{ github.repository }} | cut -d '/' -f2)
35+
echo 'Update helm version in chart.yaml and values.yaml'
36+
echo "SERVICE=${SERVICE}" >> $GITHUB_ENV
37+
helm package deploy/helm --destination .deploy
38+
cr upload -o cloudforet-io -r charts -p .deploy --token ${{ secrets.PAT_TOKEN }}
39+
cr index -i ./index.yaml -p .deploy/ -o cloudforet-io -r charts -c https://cloudforet-io.github.io/charts --token ${{ secrets.PAT_TOKEN }}
40+
cp index.yaml /tmp/index.yaml
41+
42+
- name: Check out chart repo
43+
uses: actions/checkout@master
44+
with:
45+
repository: cloudforet-io/charts
46+
ref: gh-pages
47+
token: ${{ secrets.PAT_TOKEN }}
48+
49+
- name: Update Helm repository index.yaml
50+
run: |
51+
git config --global user.email [email protected]
52+
git config --global user.name cloudforet-admin
53+
cp /tmp/index.yaml ./
54+
git add index.yaml
55+
git pull
56+
git commit -m "Add ${SERVICE} chart"
57+
git push origin gh-pages
58+
59+
- name: Notice when job fails
60+
if: failure()
61+
uses: 8398a7/[email protected]
62+
with:
63+
status: ${{job.status}}
64+
fields: repo,workflow,job
65+
author_name: Github Action Slack
66+
67+
notify_to_slack:
68+
if: github.repository_owner == 'cloudforet-io'
69+
needs: [helm_cloudforet]
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Slack
73+
if: always()
74+
uses: 8398a7/[email protected]
75+
with:
76+
status: ${{job.status}}
77+
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
78+
author_name: Github Action Slack

.github/workflows/dispatch_make_helm_chart.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)