Skip to content

Publish Docker image #408

Publish Docker image

Publish Docker image #408

name: Publish Docker image
on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
publish-docker-image:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install Cloudflare WARP
run: |
curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloudflare-client-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/cloudflare-client-archive-keyring.gpg] https://pkg.cloudflareclient.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list > /dev/null
sudo apt-get update
sudo apt-get install -y cloudflare-warp
- name: Prepare Docker image build metadata
run: |
DOCKER_IMAGE_TAG=$(warp-cli --version | sed -E "s/(WARP|warp-cli) //")
DOCKER_IMAGE_BUILD_ARG_CLOUDFLARE_WARP_VERSION=$(dpkg -s cloudflare-warp | grep "Version: " | sed "s/Version: //")
echo "DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}" >> ${GITHUB_ENV}
echo "DOCKER_IMAGE_BUILD_ARG_CLOUDFLARE_WARP_VERSION=${DOCKER_IMAGE_BUILD_ARG_CLOUDFLARE_WARP_VERSION}" >> ${GITHUB_ENV}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{github.token}}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: |
linux/amd64
linux/arm64
build-args: |
CLOUDFLARE_WARP_VERSION=${{env.DOCKER_IMAGE_BUILD_ARG_CLOUDFLARE_WARP_VERSION}}
push: ${{github.event_name != 'pull_request'}}
tags: |
ghcr.io/${{github.repository_owner}}/cloudflare-warp:${{env.DOCKER_IMAGE_TAG}}
ghcr.io/${{github.repository_owner}}/cloudflare-warp:latest