-
Notifications
You must be signed in to change notification settings - Fork 15
156 lines (148 loc) · 5.72 KB
/
flowforge-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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Flowforge - build and deploy
on:
workflow_dispatch:
inputs:
flowforge_release_name:
description: 'flowforge package version'
required: false
default: 'nightly'
flowforge_ref:
description: 'flowforge package ref'
required: false
push:
branches:
- main
paths:
- 'flowforge-container/**'
- '.github/workflows/flowforge-container.yml'
pull_request:
branches:
- main
paths:
- 'flowforge-container/**'
- '.github/workflows/flowforge-container.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
name: Build single-architecture container images
uses: flowfuse/github-actions-workflows/.github/workflows/[email protected]
with:
image_name: 'forge-k8s'
package_dependencies: |
@flowfuse/flowfuse=nightly
@flowfuse/driver-kubernetes=nightly
build_context: 'flowforge-container'
build_platform: "linux/amd64"
npm_registry_url: ${{ vars.PUBLIC_NPM_REGISTRY_URL }}
scan_image: false
secrets:
temporary_registry_token: ${{ secrets.GITHUB_TOKEN }}
upload-stage-image:
if: github.ref_name == 'main'
name: Upload image to staging registry
needs: build
# needs: build-multi-architecture
uses: flowfuse/github-actions-workflows/.github/workflows/[email protected]
with:
environment: stage
service_name: 'forge-k8s'
deployment_name: flowforge
container_name: forge
deploy: false
# image: ${{ needs.build-multi-architecture.outputs.image }}
image: ${{ needs.build.outputs.image }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
temporary_registry_token: ${{ secrets.GITHUB_TOKEN }}
eks_cluster_name: ${{ secrets.EKS_CLUSTER_NAME }}
upload-production-image:
if: github.ref_name == 'main'
name: Upload image to production registry
# needs: build-multi-architecture
needs: build
uses: flowfuse/github-actions-workflows/.github/workflows/[email protected]
with:
environment: production
service_name: 'forge-k8s'
deployment_name: flowforge
container_name: forge
deploy: false
# image: ${{ needs.build-multi-architecture.outputs.image }}
image: ${{ needs.build.outputs.image }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
temporary_registry_token: ${{ secrets.GITHUB_TOKEN }}
eks_cluster_name: ${{ secrets.EKS_CLUSTER_NAME }}
update-images:
if: github.ref_name == 'main'
name: Update images
needs: [upload-production-image, upload-stage-image]
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.GH_BOT_APP_ID }}
private_key: ${{ secrets.GH_BOT_APP_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
repository: 'FlowFuse/CloudProject'
ref: 'main'
token: ${{ steps.generate_token.outputs.token }}
- name: Install yq
uses: alexellis/arkade-get@master
with:
yq: v4.42.1
- name: Update images
run: |
production_image_value="${{ secrets.PRODUCTION_AWS_ACCOUNT_ID }}.dkr.ecr.eu-west-1.amazonaws.com/flowforge/${{ needs.upload-production-image.outputs.image }}"
staging_image_value="${{ secrets.STAGING_AWS_ACCOUNT_ID }}.dkr.ecr.eu-west-1.amazonaws.com/flowforge/${{ needs.upload-stage-image.outputs.image }}"
yq e ".forge.image = \"$production_image_value\"" -i ./production/flowfuse-values.yaml
yq e ".forge.image = \"$staging_image_value\"" -i ./staging/flowfuse-values.yaml
git config --global user.name "GitHub Actions Bot"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ./staging/flowfuse-values.yaml
git commit -m "Update forge staging image to ${{ needs.upload-stage-image.outputs.image }}"
git add ./production/flowfuse-values.yaml
git commit -m "Update forge production image to ${{ needs.upload-production-image.outputs.image }}"
git push origin main
deploy-stage:
# if: github.ref_name == 'main'
if: false
name: Deploy to staging environment
needs: build
uses: flowfuse/github-actions-workflows/.github/workflows/[email protected]
with:
environment: stage
service_name: 'forge-k8s'
deployment_name: flowforge
container_name: forge
image: ${{ needs.build-multi-architecture.outputs.image }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
temporary_registry_token: ${{ secrets.GITHUB_TOKEN }}
eks_cluster_name: ${{ secrets.EKS_CLUSTER_NAME }}
deploy-prod:
# if: github.ref_name == 'main'
if: false
name: Deploy to production environment
needs: [build, deploy-stage]
uses: flowfuse/github-actions-workflows/.github/workflows/[email protected]
with:
environment: production
service_name: 'forge-k8s'
deployment_name: flowforge
container_name: forge
image: ${{ needs.build-multi-architecture.outputs.image }}
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_ACCESS_KEY_SECRET }}
temporary_registry_token: ${{ secrets.GITHUB_TOKEN }}
eks_cluster_name: ${{ secrets.EKS_CLUSTER_NAME }}