Skip to content

Instantly share code, notes, and snippets.

@Aaronontheweb
Created April 23, 2025 18:57
Show Gist options
  • Save Aaronontheweb/563d11989ff060260d09568c4d200fe7 to your computer and use it in GitHub Desktop.
Save Aaronontheweb/563d11989ff060260d09568c4d200fe7 to your computer and use it in GitHub Desktop.
GitHub Actions `docker compose` Deploy with Tailscale
name: Publish Site to Docker
on:
push:
tags:
- '*'
jobs:
publish-docker:
name: publish-site-docker
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: "Checkout"
uses: actions/checkout@v4.2.2
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@v4.3.1
with:
global-json-file: "./global.json"
- name: "Restore .NET tools"
run: dotnet tool restore
- name: "Update release notes"
shell: pwsh
run: |
./build.ps1
- name: Tailscale
uses: tailscale/github-action@v3
with:
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:ci
- name: "build docker images"
continue-on-error: true
run: |
dotnet publish -p:ContainerRegistry={your container registry uri} -c Release -t:PublishContainer
# Copies the docker-compose file first, then updates the .env file that sets the image version
- name: Deploy to server
run: |
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ./docker/docker-compose.yaml ${{ vars.SSH_USER_NAME }}@${{ vars.TARGET_NODE }}:${{ vars.SSH_TARGET_DIRECTORY }}
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${{ vars.SSH_USER_NAME }}@${{ vars.TARGET_NODE }} << 'EOF'
cd ${{ vars.SSH_TARGET_DIRECTORY }}
sed -i 's/^DOCKER_TAG=.*/DOCKER_TAG=${{ github.ref_name }}/' .env
docker compose up -d
EOF
- name: release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: 'StannardLabs.Site ${{ github.ref_name }}'
tag_name: ${{ github.ref }}
body_path: RELEASE_NOTES.md
env:
GITHUB_TOKEN: ${{ github.token }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment