Skip to content

Publish Docker image #264

Publish Docker image

Publish Docker image #264

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: 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 [arch=amd64 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 --no-install-recommends cloudflare-warp
cp /usr/bin/warp-cli /usr/bin/warp-svc .
- 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@v5
with:
context: .
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