-
Notifications
You must be signed in to change notification settings - Fork 1
153 lines (148 loc) · 5.85 KB
/
deploy-control-plane-image-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
146
147
148
149
150
151
152
153
on: [push]
# push:
# paths:
# - control-plane/**
# - shared/**
# - .github/workflows/deploy-control-plane-image-staging.yml
# - scripts/start-cage.sh
# - scripts/health-check.sh
# branches:
# - main
name: Deploy new control plane image
env:
LINUX_TARGET: x86_64-unknown-linux-musl
jobs:
last_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install MUSL Tools
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- uses: dtolnay/[email protected]
with:
targets: x86_64-unknown-linux-musl
components: rustfmt
- uses: Swatinem/rust-cache@v2
with:
shared-key: "standard-cache"
- name: Test control plane
run: cargo test -p control-plane
get-release-semver:
needs: [last_test]
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.get-version.outputs.semver }}
semver-sha: ${{ steps.get-version.outputs.semver-sha }}
steps:
- uses: actions/checkout@v4
- name: Install MUSL Tools
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- uses: dtolnay/[email protected]
with:
targets: x86_64-unknown-linux-musl
- name: Parse semver from cargo.toml
id: get-version
run: |
SHA_SUFFIX=${GITHUB_SHA::6}
SEMVER=$(cargo metadata --no-deps | jq -r ".packages[] | select(.name == \"control-plane\") | .version")
echo "Full semver: ${SEMVER}, appending suffix: ${SHA_SUFFIX}"
echo "semver=${SEMVER}" >> $GITHUB_OUTPUT
echo "semver-sha=${SEMVER}-${SHA_SUFFIX}" >> $GITHUB_OUTPUT
deploy_control_plane_image_with_egress:
runs-on: ubuntu-latest
needs: [last_test, get-release-semver]
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v2
- name: Install MUSL Tools
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- uses: dtolnay/[email protected]
with:
targets: x86_64-unknown-linux-musl
- name: Build control plane
run: cargo build -p control-plane --features enclave,network_egress --release --target ${{ env.LINUX_TARGET }}
env:
RUSTFLAGS: "--cfg staging"
- name: Move control-plane binary to root
run: cp ./target/${{ env.LINUX_TARGET }}/release/control-plane ./control-plane
- name: Configure Staging AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_STAGING }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGING }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, and tag
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: evervault/control-plane
IMAGE_TAG: ${{ github.sha }}
SEMVER: ${{ needs.get-release-semver.outputs.semver }}
run: |
docker build -f ./control-plane/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:egress-enabled-$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:egress-enabled-$SEMVER --pull --no-cache .
- name: Push control plane image to Amazon ECR
id: push-control-plane
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: evervault/control-plane
IMAGE_TAG: ${{ github.sha }}
SEMVER: ${{ needs.get-release-semver.outputs.semver }}
run: |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:egress-enabled-$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:egress-enabled-$SEMVER
deploy_control_plane_image_without_egress:
runs-on: ubuntu-latest
needs: [last_test, get-release-semver]
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v2
- name: Install MUSL Tools
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- uses: dtolnay/[email protected]
with:
targets: x86_64-unknown-linux-musl
- name: Build control plane
run: cargo build -p control-plane --features enclave --release --target ${{ env.LINUX_TARGET }}
env:
RUSTFLAGS: "--cfg staging"
- name: Move control-plane binary to root
run: cp ./target/${{ env.LINUX_TARGET }}/release/control-plane ./control-plane
- name: Configure Staging AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_STAGING }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGING }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, and tag
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: evervault/control-plane
IMAGE_TAG: ${{ github.sha }}
SEMVER: ${{ needs.get-release-semver.outputs.semver }}
run: |
docker build -f ./control-plane/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:egress-disabled-$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:egress-disabled-$SEMVER --pull --no-cache .
- name: Push control plane image to Amazon ECR
id: push-control-plane
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: evervault/control-plane
IMAGE_TAG: ${{ github.sha }}
SEMVER: ${{ needs.get-release-semver.outputs.semver }}
run: |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:egress-disabled-$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:egress-disabled-$SEMVER