-
Notifications
You must be signed in to change notification settings - Fork 6
112 lines (100 loc) · 3.3 KB
/
cd-dev.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: cd-dev
concurrency:
group: dev
cancel-in-progress: true
on:
push:
branches:
- dev
jobs:
deploy_dev:
runs-on: ubuntu-latest
env:
ENV: "dev"
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Auth with Gcloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_DEV_SA_KEY }}
- name: Set up Gcloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: zesty-dev
- name: Set up Node
uses: actions/setup-node@v4.1.0
with:
node-version: "16.5.0"
cache: "npm"
cache-dependency-path: package-lock.json
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build:dev
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Deploy to Dev
run: gcloud app deploy app.yaml --quiet --project zesty-dev
deploy_failed_notification_to_slack:
runs-on: ubuntu-latest
if: ${{ failure() }}
needs: [deploy_dev]
steps:
- name: Failed Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: code-deploy
SLACK_COLOR: "#FF2A08"
SLACK_ICON: https://brand.zesty.io/zesty-io-logo.svg
SLACK_MESSAGE: "PR merge by ${{ github.actor }} failed to deploy."
SLACK_TITLE: "FAILED: Dev Deployment for manager-ui"
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
deploy_success_notification_to_slack:
runs-on: ubuntu-latest
if: ${{ success() }}
needs: [deploy_dev]
steps:
- name: Success Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: code-deploy
SLACK_COLOR: "#75BF43"
SLACK_ICON: https://brand.zesty.io/zesty-io-logo.svg
# SLACK_MESSAGE: "PR merge by ${{ github.actor }} has been deployed to stage."
SLACK_TITLE: "DEV:manager-ui"
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
create_stage_pr:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Retrive latest branches
run: git fetch origin
- name: Get origin branch list
run: |
echo "origin_branch_list=$(git branch -r --list origin/stage | xargs)" >> "$GITHUB_ENV"
- name: Ensure origin/stage branch exists
if: env.origin_branch_list != 'origin/stage'
run: git checkout dev && git switch --create stage && git push -u origin stage
- name: Check if PR exists
id: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
prs=$(gh pr list \
--repo "$GITHUB_REPOSITORY" \
--head 'dev' \
--base 'stage' \
--json title \
--jq 'length')
if ((prs > 0)); then
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
- name: Create Stage Release
if: "!steps.check.outputs.skip"
run: gh pr create -B stage -H dev --title 'Stage Release' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}