tailscale derper checking #318
This file contains hidden or 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: tailscale derper checking | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'Dockerfile' | |
| - 'entrypoint.sh' | |
| workflow_run: | |
| workflows: ["Update Tailscale"] | |
| types: | |
| - completed | |
| jobs: | |
| build-publish: | |
| strategy: | |
| matrix: | |
| channel: [latest, nightly] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Trigger type | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_run" ]; then | |
| echo "trigger_type=workflow_run" >> $GITHUB_ENV | |
| else | |
| echo "trigger_type=others" >> $GITHUB_ENV | |
| fi | |
| - name: Check for derper changes (Only for submodule updates) | |
| if: env.trigger_type == 'workflow_run' | |
| run: | | |
| git fetch origin tag derper-changed --no-tags || true | |
| if git show-ref --tags derper-changed > /dev/null 2>&1; then | |
| FLAG=$(git for-each-ref --format='%(contents)' refs/tags/derper-changed) | |
| else | |
| FLAG=0 | |
| fi | |
| echo "trigger_deploy=$FLAG" >> $GITHUB_ENV | |
| echo "derper-changed flag is $FLAG" | |
| - name: Deploy if required | |
| run: | | |
| if [[ "$trigger_type" == "others" || "$trigger_deploy" == "1" ]]; then | |
| echo "Deploying..." | |
| else | |
| echo "No deploy needed." | |
| exit 0 | |
| fi | |
| - name: Select version | |
| run: | | |
| if [[ "$trigger_type" == "others" || "$trigger_deploy" == "1" ]]; then | |
| if [[ "${{ matrix.channel }}" == "latest" ]]; then | |
| TAG=$(git -C third_party/tailscale tag -l \ | |
| | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \ | |
| | sort -Vr | head -n1) | |
| git -C third_party/tailscale switch --detach "$TAG" | |
| echo "IMAGE_TAG=latest" >> $GITHUB_ENV | |
| echo "EXTRA_TAG=$TAG" >> $GITHUB_ENV | |
| else | |
| git -C third_party/tailscale switch --detach main | |
| SHA=$(git -C third_party/tailscale rev-parse --short HEAD) | |
| echo "IMAGE_TAG=nightly" >> $GITHUB_ENV | |
| echo "EXTRA_TAG=$SHA" >> $GITHUB_ENV | |
| fi | |
| fi | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| if: env.trigger_type == 'others' || env.trigger_deploy == '1' | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| if: env.trigger_type == 'others' || env.trigger_deploy == '1' | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| if: env.trigger_type == 'others' || env.trigger_deploy == '1' | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| if: env.trigger_type == 'others' || env.trigger_deploy == '1' | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker images to docker.io and ghcr.io | |
| uses: docker/build-push-action@v6 | |
| if: env.trigger_type == 'others' || env.trigger_deploy == '1' | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| context: . | |
| push: true | |
| tags: | | |
| camllia/derper:${{ env.IMAGE_TAG }} | |
| camllia/derper:${{ env.EXTRA_TAG }} | |
| ghcr.io/xavieralpha/derper:${{ env.IMAGE_TAG }} |