-
Notifications
You must be signed in to change notification settings - Fork 7
90 lines (85 loc) · 2.85 KB
/
build-xmtpd.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
name: Build xmtpd image
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
push_to_registry:
strategy:
matrix:
image: ["xmtpd", "xmtpd-cli"]
name: Push Docker Images to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
DOCKER_METADATA_PR_HEAD_SHA: true
outputs:
xmtpd_digest: ${{ steps.set_xmtpd_digest.outputs.digest }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/xmtp/${{ matrix.image }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
- name: Set up Docker image file based on the matrix variable
id: set_dockerfile
run: |
if [[ "${{ matrix.image }}" == "xmtpd" ]]; then
echo "dockerfile=Dockerfile" >> $GITHUB_OUTPUT
elif [[ "${{ matrix.image }}" == "xmtpd-cli" ]]; then
echo "dockerfile=Dockerfile-cli" >> $GITHUB_OUTPUT
else
echo "Unknown image: ${{ matrix.image }}"
exit 1
fi
- name: Build and push Docker image
uses: docker/build-push-action@v6
id: push
with:
context: .
file: ./dev/docker/${{ steps.set_dockerfile.outputs.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: "GIT_COMMIT=${{ github.event_name != 'pull_request' && github.sha || github.event.pull_request.head.sha }}"
- name: Set xmtpd digest output
if: ${{ matrix.image == 'xmtpd' }}
id: set_xmtpd_digest
run: echo "digest=${{ steps.push.outputs.digest }}" >> $GITHUB_OUTPUT
deploy:
name: Deploy new images to infra
runs-on: ubuntu-latest
needs: push_to_registry
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy Testnet
uses: xmtp-labs/terraform-deployer@v1
timeout-minutes: 45
with:
timeout: 45m
terraform-token: ${{ secrets.TERRAFORM_TOKEN }}
terraform-org: xmtp
terraform-workspace: testnet-staging
variable-name: xmtpd_server_docker_image
variable-value: "ghcr.io/xmtp/xmtpd@${{ needs.push_to_registry.outputs.xmtpd_digest }}"
variable-value-required-prefix: "ghcr.io/xmtp/xmtpd@sha256:"