-
Notifications
You must be signed in to change notification settings - Fork 14
122 lines (109 loc) · 4.24 KB
/
fileserver-container.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
name: Build file-server container
on:
workflow_dispatch:
inputs:
fileserver_release_name:
description: 'file-server package version'
required: false
default: 'nightly'
fileserver_ref:
description: 'file-server package ref'
required: false
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-stage:
uses: flowforge/github-actions-workflows/.github/workflows/build_container_image.yml@e3e734b910af78371b2c9a1c6856446d17421f50
with:
environment: 'stage'
image_name: 'file-server'
package_dependencies: |
@flowforge/file-server
build_context: 'file-server'
npm_registry_url: ${{ vars.PUBLIC_NPM_REGISTRY_URL }}
secrets:
npm_registry_auth_token: ${{ secrets.NPM_PUBLISH_TOKEN }}
aws_access_key_id: ${{ secrets.STAGING_AWS_ID }}
aws_access_key_secret: ${{ secrets.STAGING_AWS_KEY }}
build-prod:
name: Build production image
if: false
uses: flowforge/github-actions-workflows/.github/workflows/build_container_image.yml@e3e734b910af78371b2c9a1c6856446d17421f50
with:
environment: 'production'
image_name: 'file-server'
package_dependencies: |
@flowforge/file-server
build_context: 'file-server'
npm_registry_url: ${{ vars.PUBLIC_NPM_REGISTRY_URL }}
secrets:
npm_registry_auth_token: ${{ secrets.NPM_PUBLISH_TOKEN }}
aws_access_key_id: ${{ secrets.PRODUCTION_AWS_ID }}
aws_access_key_secret: ${{ secrets.PRODUCTION_AWS_KEY }}
deploy-stage:
name: Deploy to staging environment
environment: stage
runs-on: ubuntu-latest
needs: build-stage
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.STAGING_AWS_ID }}
aws-secret-access-key: ${{ secrets.STAGING_AWS_KEY }}
aws-region: eu-west-1
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/K8sAdmin
role-duration-seconds: 1200
- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.23.4'
- name: Configure kubectl
run:
aws eks update-kubeconfig --region eu-west-1 --name ${{ secrets.EKS_CLUSTER_NAME }}
- name: Update image and wait for deployment to finish
timeout-minutes: 5
run: |
kubectl -n default set image deployment/flowforge-file file-storage=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-west-1.amazonaws.com/flowforge/${{ needs.build-stage.outputs.image }}
kubectl -n default rollout status deployment/flowforge-file
- name: Rollback failed deployment
if: failure()
run: |
kubectl -n default rollout undo deployment/flowforge-file
kubectl -n default rollout status deployment/flowforge-file
deploy-prod:
if: false
name: Deploy to production environment
environment: production
runs-on: ubuntu-latest
needs: [build-prod, deploy-stage]
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.PRODUCTION_AWS_ID }}
aws-secret-access-key: ${{ secrets.PRODUCTION_AWS_KEY }}
aws-region: eu-west-1
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/K8sAdmin
role-duration-seconds: 1200
- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.23.4'
- name: Configure kubectl
run:
aws eks update-kubeconfig --region eu-west-1 --name ${{ secrets.EKS_CLUSTER_NAME }}
- name: Update image and wait for deployment to finish
timeout-minutes: 5
run: |
kubectl -n default set image deployment/flowforge-file file-storage=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.eu-west-1.amazonaws.com/flowforge/${{ needs.build-prod.outputs.image }}
kubectl -n default rollout status deployment/flowforge-file
- name: Rollback failed deployment
if: failure()
run: |
kubectl -n default rollout undo deployment/flowforge-file
kubectl -n default rollout status deployment/flowforge-file