Docker Image #1
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: Docker Image | |
on: | |
push: | |
branches: [main] | |
schedule: | |
# Runs "every Monday" (see https://crontab.guru) | |
- cron: '0 0 * * MON' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Log in to GitHub Docker Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get latest tailscale version | |
run: | | |
::set-env name=TAILSCALE_VERSION::$(curl -s \ | |
https://api.github.com/repos/tailscale/tailscale/releases/latest | jq -r '.tag_name') | |
echo "Latest tailscale version: $TAILSCALE_VERSION" | |
- name: Check if the image already exists | |
run: | | |
GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64) | |
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ | |
-H "Authorization: Bearer $GHCR_TOKEN" \ | |
https://ghcr.io/v2/${{ github.repository }}/manifests/${{ env.TAILSCALE_VERSION }} | |
) | |
echo "HTTP code: $HTTP_CODE" | |
::set-env name=IMAGE_EXISTS::${HTTP_CODE == '200'} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
if: ${{ env.IMAGE_EXISTS == 'false' }} | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
if: ${{ env.IMAGE_EXISTS == 'false' }} | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: linux/amd64, linux/arm64 | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository }}:${{ env.TAILSCALE_VERSION }} | |
ghcr.io/${{ github.repository }}:latest | |
build-args: | | |
DERP_VERSION=${TAILSCALE_VERSION} |