Skip to content

Publish Docker image #1545

Publish Docker image

Publish Docker image #1545

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@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 [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 cloudflare-warp
cp /usr/bin/warp-cli /usr/bin/warp-svc .
- name: Prepare Docker image build metadata
id: 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_OUTPUT
echo "DOCKER_IMAGE_BUILD_ARG_CLOUDFLARE_WARP_VERSION=$DOCKER_IMAGE_BUILD_ARG_CLOUDFLARE_WARP_VERSION" >> $GITHUB_OUTPUT
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{github.token}}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
build-args: CLOUDFLARE_WARP_VERSION=${{steps.prepare-docker-image-build-metadata.outputs.DOCKER_IMAGE_BUILD_ARG_CLOUDFLARE_WARP_VERSION}}
push: ${{github.event_name != 'pull_request'}}
tags: |
${{secrets.DOCKER_USERNAME}}/cloudflare-warp:${{steps.prepare-docker-image-build-metadata.outputs.DOCKER_IMAGE_TAG}}
${{secrets.DOCKER_USERNAME}}/cloudflare-warp:latest
ghcr.io/${{github.repository_owner}}/cloudflare-warp:${{steps.prepare-docker-image-build-metadata.outputs.DOCKER_IMAGE_TAG}}
ghcr.io/${{github.repository_owner}}/cloudflare-warp:latest