-
Notifications
You must be signed in to change notification settings - Fork 161
122 lines (110 loc) · 4.17 KB
/
deploy.yaml
File metadata and controls
122 lines (110 loc) · 4.17 KB
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: deploy
on:
push:
branches: [main]
tags: [v*]
workflow_dispatch:
inputs:
predefined_feature:
description: 'Select a predefined feature'
type: choice
options:
- 'None'
- 'mimalloc-allocator'
- 'tokio-console'
default: 'None'
required: false
custom_features:
description: 'Additional custom features (space-separated, e.g., "feature1 feature2")'
type: string
required: false
default: ''
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Without this the fetch depth defaults to 1, which only includes the most recent commit. We want to know the full history so that `git describe` can give more information when it is invoked in the orderbook's crate build script.
fetch-depth: '0'
persist-credentials: false
- uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare build features
id: features
run: |
FEATURES=""
if [ "${{ github.event.inputs.predefined_feature }}" != "None" ]; then
FEATURES="${{ github.event.inputs.predefined_feature }}"
fi
if [ -n "${{ github.event.inputs.custom_features }}" ]; then
FEATURES="${FEATURES:+$FEATURES }${{ github.event.inputs.custom_features }}"
fi
if [ -n "$FEATURES" ]; then
CARGO_FEATURES="--features $FEATURES"
fi
if echo "$FEATURES" | grep -q "tokio-console"; then
RUSTFLAGS="--cfg tokio_unstable"
fi
echo "cargo_features=$CARGO_FEATURES" >> $GITHUB_OUTPUT
echo "rustflags=$RUSTFLAGS" >> $GITHUB_OUTPUT
echo "Combined features: $FEATURES"
echo "Cargo features arg: $CARGO_FEATURES"
echo "RUSTFLAGS: $RUSTFLAGS"
- name: Services image metadata
id: meta_services
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=sha
type=ref,event=branch
type=ref,event=tag
labels: |
org.opencontainers.image.licenses=GPL-3.0-or-later
- name: Services image build
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta_services.outputs.tags }}
labels: ${{ steps.meta_services.outputs.labels }}
build-args: |
CARGO_BUILD_FEATURES=${{ steps.features.outputs.cargo_features }}
RUSTFLAGS=${{ steps.features.outputs.rustflags }}
- name: Migration image metadata
id: meta_migration
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
with:
images: ghcr.io/${{ github.repository }}-migration
tags: |
type=sha
type=ref,event=branch
type=ref,event=tag
labels: |
org.opencontainers.image.licenses=GPL-3.0-or-later
- name: Migration image build
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
file: Dockerfile
target: migrations
push: true
tags: ${{ steps.meta_migration.outputs.tags }}
labels: ${{ steps.meta_migration.outputs.labels }}
- uses: cowprotocol/autodeploy-action@73f1163f19a584cdc34e29aa84d630d7e6a45432 # v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
images: ghcr.io/cowprotocol/services:main
strategy: restart # Recreates the deployment
tag: ${{ secrets.AUTODEPLOY_TAG }}
url: ${{ secrets.AUTODEPLOY_URL }}
token: ${{ secrets.AUTODEPLOY_TOKEN }}
timeout: 600000 # 10 minutes