-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathrelease-mls-validation-service.yml
More file actions
102 lines (91 loc) · 3.49 KB
/
Copy pathrelease-mls-validation-service.yml
File metadata and controls
102 lines (91 loc) · 3.49 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
name: Build (and push/deploy) MLS Validation Service
on:
push:
branches: [ main ] # main: push SHA tag
pull_request: # PRs: build only
workflow_dispatch: # manual: full tags + deploy
jobs:
push_to_registry:
name: Build MLS Validation Docker Image
runs-on: warp-ubuntu-latest-x64-16x
permissions:
contents: read
packages: write
outputs:
digest: ${{ steps.build.outputs.digest }}
env:
IMAGE: ghcr.io/${{ github.repository_owner }}/mls-validation-service
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install toml-cli
run: cargo install toml-cli
- name: Get Crate Version
id: version
run: echo "version=$(toml get -r Cargo.toml workspace.package.version)" >> "$GITHUB_OUTPUT"
# ---- Metadata per mode ----
- name: Metadata (manual/full)
id: meta_full
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE }}
tags: |
type=raw,value=v${{ steps.version.outputs.version }}
type=raw,value=${{ steps.version.outputs.version }}
type=sha
type=raw,value=latest
- name: Metadata (main/sha-only)
id: meta_sha
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE }}
tags: |
type=sha
- name: Metadata (PR/non-main build-only)
id: meta_ci
if: ${{ github.event_name == 'pull_request' }}
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE }}
tags: |
type=raw,value=ci-${{ github.sha }}
# ---- Login only when pushing ----
- name: Log in to GHCR
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# ---- Single build step with conditional push ----
- name: Build (and conditionally push)
id: build
uses: docker/build-push-action@v7
with:
context: .
file: ./dev/validation_service/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta_full.outputs.tags || steps.meta_sha.outputs.tags || steps.meta_ci.outputs.tags }}
labels: ${{ steps.meta_full.outputs.labels || steps.meta_sha.outputs.labels || steps.meta_ci.outputs.labels }}
deploy:
name: Deploy new MLS validation image to infra
runs-on: ubuntu-latest
needs: push_to_registry
if: ${{ github.event_name == 'workflow_dispatch' }} # manual only
strategy:
matrix:
environment: [ dev, production, testnet ]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Deploy to ${{ matrix.environment }}
uses: xmtp-labs/terraform-deployer@v1
with:
terraform-token: ${{ secrets.TERRAFORM_TOKEN }}
terraform-org: xmtp
terraform-workspace: ${{ matrix.environment }}
variable-name: validation_service_image
variable-value: "ghcr.io/xmtp/mls-validation-service@${{ needs.push_to_registry.outputs.digest }}"
variable-value-required-prefix: "ghcr.io/xmtp/mls-validation-service@sha256:"