-
Notifications
You must be signed in to change notification settings - Fork 13
145 lines (123 loc) · 4.84 KB
/
build-and-deploy-staging.yml
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Deploy Auctions UI staging
on:
push:
branches: [ main ]
jobs:
build-frontend:
name: build frontend
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GH_WORKFLOW_USER }}
password: ${{ secrets.GH_WORKFLOW_TOKEN }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::802385070966:role/GithubActionsSSMRole
role-session-name: AuctionsUiSession
- name: Get secrets from parameterstore
uses: dkershner6/aws-ssm-getparameters-action@v2
with:
parameterPairs: "/auction-ui/main.auction-ui.k8s.sidestream.tech/frontend/rpc_url = RPC_URL, /auction-ui/main.auction-ui.k8s.sidestream.tech/frontend/contact_email = CONTACT_EMAIL, /auction-ui/main.auction-ui.k8s.sidestream.tech/frontend/frontend_origin = FRONTEND_ORIGIN, /auction-ui/main.auction-ui.k8s.sidestream.tech/frontend/infura_project_id = INFURA_POJECT_ID, /auction-ui/main.auction-ui.k8s.sidestream.tech/frontend/heapio_id = HEAPIO_ID, /auction-ui/main.auction-ui.k8s.sidestream.tech/frontend/production_domain = PRODUCTION_DOMAIN, /auction-ui/main.auction-ui.k8s.sidestream.tech/frontend/staging_banner_url = STAGING_BANNER_URL"
withDecryption: "true"
- name: Set outputs
id: vars
run: echo "git_hash_short=$(git rev-parse --short ${GITHUB_SHA})" >> $GITHUB_OUTPUT
- name: build and push frontend
uses: docker/build-push-action@v6
with:
file: frontend/Dockerfile
context: ./
platforms: linux/amd64
tags: |
ghcr.io/sidestream-tech/unified-auctions-ui/frontend:${{ github.sha }}
build-args: |
RPC_URL=${{ env.RPC_URL }}
PRODUCTION_DOMAIN=${{ env.PRODUCTION_DOMAIN }}
CONTACT_EMAIL=${{ env.CONTACT_EMAIL }}
STAGING_BANNER_URL=${{ env.STAGING_BANNER_URL }}
HEAPIO_ID=${{ env.HEAPIO_ID }}
FRONTEND_ORIGIN=${{ env.FRONTEND_ORIGIN }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-bot:
name: build bot
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GH_WORKFLOW_USER }}
password: ${{ secrets.GH_WORKFLOW_TOKEN }}
- name: Set outputs
id: vars
run: echo "git_hash_short=$(git rev-parse --short ${GITHUB_SHA})" >> $GITHUB_OUTPUT
- name: build and push bot
uses: docker/build-push-action@v6
with:
file: bot/Dockerfile
context: ./
platforms: linux/amd64
tags: |
ghcr.io/sidestream-tech/unified-auctions-ui/bot:${{ github.sha }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: deploy staging to cluster
needs:
- build-frontend
- build-bot
runs-on: ubuntu-latest
steps:
- name: Checkout k8s-projects Repo
uses: actions/checkout@v4
with:
repository: sidestream-tech/k8s-projects
token: ${{ secrets.GH_WORKFLOW_TOKEN }}
path: k8s-projects
ref: main
- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 6
- name: Update Auctions-UI Value File for frontend
uses: mikefarah/yq@master
with:
cmd: yq -i '(.image.tag ="${{ github.sha }}") | (.commitShortSHA ="${{ github.sha }}") | (.releaseTag ="${{ github.ref_name }}")' $VALUES_FILE
env:
VALUES_FILE: "k8s-projects/auctions-ui/staging/values-frontend.yml"
- name: Update Auctions-UI Value File for bot
uses: mikefarah/yq@master
with:
cmd: yq -i '(.image.tag ="${{ github.sha }}") | (.commitShortSHA ="${{ github.sha }}") | (.releaseTag ="${{ github.ref_name }}")' $VALUES_FILE
env:
VALUES_FILE: "k8s-projects/auctions-ui/staging/values-bot.yml"
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GH_WORKFLOW_TOKEN }}
repository: sidestream-tech/k8s-projects
branch: main
message: "[ArgoCD]: ${{ github.workflow }} to `${{ steps.short-sha.outputs.sha }}` :rocket:"
directory: k8s-projects