Build CLI Docker Image #596
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
id: push | ||
with: | ||
context: . | ||
file: ./dev/docker/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_ENV | ||
outputs: | ||
digest: ${{ steps.push.outputs.digest }} | ||
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 | ||
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:" |